{"record":{"id":"6b43b0c75f8b19b9","repo":"microsoft/FASTER","slug":"invalid-enum-argument","errorCode":null,"errorMessage":"Invalid Enum Argument","messagePattern":"Invalid Enum Argument","errorType":"exception","errorClass":"FasterException","httpStatus":null,"severity":"error","filePath":"cs/src/core/Index/Synchronization/IndexResizeStateMachine.cs","lineNumber":44,"sourceCode":"                    break;\n                case Phase.IN_PROGRESS_GROW:\n                    // Set up the transition to new version of HT\n                    var numChunks = (int) (faster.state[faster.resizeInfo.version].size / Constants.kSizeofChunk);\n                    if (numChunks == 0) numChunks = 1; // at least one chunk\n\n                    faster.numPendingChunksToBeSplit = numChunks;\n                    faster.splitStatus = new long[numChunks];\n                    faster.overflowBucketsAllocatorResize = faster.overflowBucketsAllocator;\n                    faster.overflowBucketsAllocator = new MallocFixedPageSize<HashBucket>();\n                    faster.Initialize(1 - faster.resizeInfo.version, faster.state[faster.resizeInfo.version].size * 2, faster.sectorSize);\n\n                    faster.resizeInfo.version = 1 - faster.resizeInfo.version;\n                    break;\n                case Phase.REST:\n                    // nothing to do\n                    break;\n                default:\n                    throw new FasterException(\"Invalid Enum Argument\");\n            }\n        }\n\n        /// <inheritdoc />\n        public void GlobalAfterEnteringState<Key, Value>(\n            SystemState next,\n            FasterKV<Key, Value> faster)\n        {\n            switch (next.Phase)\n            {\n                case Phase.PREPARE_GROW:\n                    bool isProtected = faster.epoch.ThisInstanceProtected();\n                    if (!isProtected)\n                        faster.epoch.Resume();\n                    try\n                    {\n                        faster.epoch.BumpCurrentEpoch(() => allThreadsInPrepareGrow = true);\n                    }","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/src/core/Index/Synchronization/IndexResizeStateMachine.cs#L26-L62","documentation":"IndexResizeStateMachine.GlobalBeforeEnteringState switches on the current Phase to prepare the system before entering the next state during an index resize. Any Phase value outside the handled cases (PREPARE_GROW, IN_PROGRESS_GROW, WAIT, REST, etc.) falls into the default branch, which throws this exception. It is an internal exhaustive-switch guard, not a user input validation error.","triggerScenarios":"An internal state-machine corruption during an index resize: a phase value that the resize state machine never expects, typically due to a concurrent checkpoint/resize collision or a bug in phase transitions, not direct API misuse.","commonSituations":"Calling ResizeIndex while a version change or snapshot is in flight; resuming a resize after an unclean crash left resizeInfo in an unexpected phase; concurrent ResizeIndex calls.","solutions":["Ensure no checkpoint or version change operation is running concurrently with ResizeIndex; serialize index maintenance operations.","Restart the process and retry the resize from a clean REST phase state.","If reproducible, file a bug with the phase value and operation trace - this indicates an internal state machine violation."],"exampleFix":"// before\nawait faster.TakeCheckpointAsync();\nfaster.ResizeIndex(newSize); // concurrent ops may corrupt phase transitions\n// after\nawait faster.TakeCheckpointAsync(); // await completion first\nawait faster.ResizeIndexAsync(newSize); // run resize exclusively","handlingStrategy":"try-catch","validationCode":"// Ensure no other state-machine op is active before resizing\nif (Interlocked.CompareExchange(ref resizeInProgress, 1, 0) != 0)\n    throw new InvalidOperationException(\"Another index maintenance operation is in progress.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    faster.ResizeIndex(newSize);\n}\ncatch (FasterException ex) when (ex.Message == \"Invalid Enum Argument\")\n{\n    logger.LogError(ex, \"Index resize state machine corrupted; restart required\");\n    throw;\n}","preventionTips":["Never call ResizeIndex concurrently with checkpoints or version changes.","Drain pending operations (CompletePending) before index maintenance.","Treat any occurrence as a bug signal and capture full traces."],"tags":["faster","index","resize","state-machine"],"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-16T04:17:20.429Z"}