{"record":{"id":"0142369e32a4e67d","repo":"alibaba/COLA","slug":"currentstateid-is-not-found-please-check-state","errorCode":null,"errorMessage":"${currentStateId} is not found, please check state machine","messagePattern":"(.+?) is not found, please check state machine","errorType":"exception","errorClass":"StateMachineException","httpStatus":null,"severity":"error","filePath":"cola-components/cola-component-statemachine/src/main/java/com/alibaba/cola/statemachine/impl/StateMachineImpl.java","lineNumber":124,"sourceCode":"        }\n\n        for (Transition<S, E, C> transition : transitions) {\n            Transition<S, E, C> transit = null;\n            if (transition.getCondition() == null) {\n                transit = transition;\n            } else if (transition.getCondition().isSatisfied(context)) {\n                transit = transition;\n            }\n            result.add(transit);\n        }\n        return result;\n    }\n\n    private State getState(S currentStateId) {\n        State state = StateHelper.getState(stateMap, currentStateId);\n        if (state == null) {\n            showStateMachine();\n            throw new StateMachineException(currentStateId + \" is not found, please check state machine\");\n        }\n        return state;\n    }\n\n    private void isReady() {\n        if (!ready) {\n            throw new StateMachineException(\"State machine is not built yet, can not work\");\n        }\n    }\n\n    @Override\n    public String accept(Visitor visitor) {\n        StringBuilder sb = new StringBuilder();\n        sb.append(visitor.visitOnEntry(this));\n        for (State state : stateMap.values()) {\n            sb.append(state.accept(visitor));\n        }\n        sb.append(visitor.visitOnExit(this));","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/alibaba/COLA/blob/352e1a867538d9cd40e1b11e4028fa652fc97557/cola-components/cola-component-statemachine/src/main/java/com/alibaba/cola/statemachine/impl/StateMachineImpl.java#L106-L142","documentation":"StateMachineImpl.getState() resolves a state id to a State object from the machine's stateMap; when the id is absent it dumps the machine structure (showStateMachine) and throws this StateMachineException. It means fireEvent was given a source state that the machine does not define.","triggerScenarios":"fireEvent(currentStateId, event, context) with a currentStateId that was never registered in the builder, a misspelled state id, or a stale state reference from an older machine version.","commonSituations":"Typos in state constants; callers tracking state externally (e.g. DB) with values from a different machine definition; state ids renamed during refactoring.","solutions":["Ensure the state passed to fireEvent is one defined via builder states(); use shared constants for state ids","Validate/normalize externally stored state values before firing events","Check the printed state machine structure in the exception output to see the valid state ids","If state comes from persistence, map legacy ids to current machine state ids"],"exampleFix":"// before\nsm.fireEvent(\"STAE_A\", event, ctx); // typo -> throws\n\n// after\nprivate static final String STATE_A = \"STATE_A\";\nsm.fireEvent(STATE_A, event, ctx); // defined in builder","handlingStrategy":"validation","validationCode":"// maintain the set of state ids registered in the builder\nif (!definedStateIds.contains(currentStateId)) {\n    throw new IllegalStateException(\"unknown state id: \" + currentStateId);\n}","typeGuard":null,"tryCatchPattern":"try {\n    sm.fireEvent(stateId, event, ctx);\n} catch (StateMachineException e) {\n    if (e.getMessage().endsWith(\"is not found, please check state machine\")) {\n        // repair or reset externally persisted state to a defined state\n    } else {\n        throw e;\n    }\n}","preventionTips":["Use shared constants/enums for state ids","Validate persisted state values against machine definitions","Keep exception output's printed machine structure to debug id mismatches","Map legacy state ids during refactors"],"tags":["statemachine","resource-not-found","state"],"backgroundTag":"entity-not-found","analyzedSha":"352e1a867538d9cd40e1b11e4028fa652fc97557","analyzedAt":"2026-09-08T00:46:23.972Z","contentChangedAt":"2026-09-08T00:46:23.972Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}