{"record":{"id":"cbee338b526e4afe","repo":"apache/cassandra","slug":"step-s-is-invalid-for-sequence-s-cbee33","errorCode":null,"errorMessage":"Step %s is invalid for sequence %s ","messagePattern":"Step (.+?) is invalid for sequence (.+?) ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tcm/sequences/BootstrapAndReplace.java","lineNumber":385,"sourceCode":"                                        .forEach(source -> movements.put(destination, source));\n            });\n            movementMapBuilder.put(params, movements.build());\n        });\n        return movementMapBuilder.build();\n    }\n\n    private static int nextToIndex(Transformation.Kind next)\n    {\n        switch (next)\n        {\n            case START_REPLACE:\n                return 0;\n            case MID_REPLACE:\n                return 1;\n            case FINISH_REPLACE:\n                return 2;\n            default:\n                throw new IllegalStateException(String.format(\"Step %s is invalid for sequence %s \", next, REPLACE));\n        }\n    }\n\n    private static Transformation.Kind indexToNext(int index)\n    {\n        switch (index)\n        {\n            case 0:\n                return START_REPLACE;\n            case 1:\n                return MID_REPLACE;\n            case 2:\n                return FINISH_REPLACE;\n            default:\n                throw new IllegalStateException(String.format(\"Step %s is invalid for sequence %s \", index, REPLACE));\n        }\n    }\n","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tcm/sequences/BootstrapAndReplace.java#L367-L403","documentation":"BootstrapAndReplace.nextToIndex maps the replace sequence's Transformation.Kind (START_REPLACE=0, MID_REPLACE=1, FINISH_REPLACE=2) to an ordinal index. IllegalStateException is thrown for kinds outside the replace sequence, which cannot occur in a well-formed BootstrapAndReplace.","triggerScenarios":"Constructing or advancing a BootstrapAndReplace whose current step is a JOIN-family kind or other non-replace Transformation.Kind, typically from malformed metadata or a wrong-argument construction.","commonSituations":"Transformation log corruption/replay assigns a join kind to a replace sequence; a developer passes the wrong kind into the BootstrapAndReplace constructor; version skew between nodes interpreting transformation kinds differently.","solutions":["Validate the stored Transformation.Kind belongs to the replace family before constructing the sequence","Re-fetch/replay cluster metadata to obtain a consistent transformation state","Check construction sites so BootstrapAndReplace only receives START_REPLACE/MID_REPLACE/FINISH_REPLACE","Upgrade all nodes consistently if version skew over transformation kinds is suspected"],"exampleFix":"// before\nBootstrapAndReplace seq = new BootstrapAndReplace(replacement, next, ...);\n// after\nif (next != Transformation.Kind.START_REPLACE && next != MID_REPLACE && next != FINISH_REPLACE)\n    throw new IllegalArgumentException(\"kind not part of BootstrapAndReplace: \" + next);\nBootstrapAndReplace seq = new BootstrapAndReplace(replacement, next, ...);","handlingStrategy":"validation","validationCode":"Set<Transformation.Kind> replaceKinds = Set.of(START_REPLACE, MID_REPLACE, FINISH_REPLACE);\nif (!replaceKinds.contains(kind)) throw new IllegalArgumentException(\"not a replace kind: \" + kind);","typeGuard":null,"tryCatchPattern":"try { BootstrapAndReplace seq = reconstruct(state); } catch (IllegalStateException e) { /* re-read metadata / repair transformation log */ }","preventionTips":["Construct BootstrapAndReplace only with replace-family kinds","Validate kinds when replaying metadata transformations","Keep transformation-kind definitions consistent across node versions"],"tags":["tcm","replace","state-machine","sequence","illegal-state"],"backgroundTag":"invalid-enum-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}