{"record":{"id":"fdd8be7cfa87a63e","repo":"microsoft/FASTER","slug":"invalid-enum-argument-indexsnapshotstatemachine","errorCode":null,"errorMessage":"Invalid Enum Argument","messagePattern":"Invalid Enum Argument","errorType":"exception","errorClass":"FasterException","httpStatus":null,"severity":"error","filePath":"cs/src/core/Index/Synchronization/IndexSnapshotStateMachine.cs","lineNumber":126,"sourceCode":"        }\n\n        /// <inheritdoc />\n        public override SystemState NextState(SystemState start)\n        {\n            var result = SystemState.Copy(ref start);\n            switch (start.Phase)\n            {\n                case Phase.REST:\n                    result.Phase = Phase.PREP_INDEX_CHECKPOINT;\n                    break;\n                case Phase.PREP_INDEX_CHECKPOINT:\n                    result.Phase = Phase.WAIT_INDEX_ONLY_CHECKPOINT;\n                    break;\n                case Phase.WAIT_INDEX_ONLY_CHECKPOINT:\n                    result.Phase = Phase.REST;\n                    break;\n                default:\n                    throw new FasterException(\"Invalid Enum Argument\");\n            }\n\n            return result;\n        }\n    }\n}","sourceCodeStart":108,"sourceCodeEnd":132,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/src/core/Index/Synchronization/IndexSnapshotStateMachine.cs#L108-L132","documentation":"IndexSnapshotStateMachine.NextState advances the phases of an index snapshot (WAIT_FLUSH -> WAIT_INDEX_CHECKPOINT -> WAIT_INDEX_ONLY_CHECKPOINT -> REST). An unrecognized Phase falls into the default branch, which throws this exception. It indicates the snapshot state machine encountered a phase outside its defined transitions - an internal invariant violation.","triggerScenarios":"Internal phase corruption while TakeIndexCheckpoint/TakeCheckpoint executes the index snapshot state machine; typically from concurrent state machine overlap or resuming corrupted checkpoint state after a crash.","commonSituations":"Calling snapshot/checkpoint operations concurrently on the same FASTER instance; recovering a checkpoint directory written by a crashed snapshot.","solutions":["Serialize checkpoint/snapshot calls - never issue two state-machine operations concurrently.","Restart the process and retake the checkpoint.","Report a bug with repro details if the exception fires in a single-threaded checkpoint flow."],"exampleFix":"// before\n_ = faster.TakeIndexCheckpointAsync();\nawait faster.TakeCheckpointAsync(); // overlapping state machines\n// after\nawait faster.TakeCheckpointAsync(); // one state machine at a time\nawait faster.TakeIndexCheckpointAsync();","handlingStrategy":"try-catch","validationCode":"// Serialize checkpoint operations behind a semaphore\nif (!await checkpointSemaphore.WaitAsync(0))\n    throw new InvalidOperationException(\"A checkpoint/snapshot is already running.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    await faster.TakeIndexCheckpointAsync();\n}\ncatch (FasterException ex) when (ex.Message == \"Invalid Enum Argument\")\n{\n    logger.LogError(ex, \"Index snapshot state machine corrupted; retake checkpoint after restart\");\n    throw;\n}","preventionTips":["Issue one checkpoint/snapshot at a time; await each before the next.","Clean up partially written checkpoint directories after crashes.","Capture stack traces when this fires and report upstream."],"tags":["faster","snapshot","state-machine","checkpoint"],"backgroundTag":"invalid-enum-value","analyzedSha":"321d872eabda6a0345c8bd76419f89723ed864ae","analyzedAt":"2026-09-15T22:18:00.693Z","contentChangedAt":"2026-09-15T22:18:00.693Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}