{"record":{"id":"cb59facfd986bf9c","repo":"HumanSignal/label-studio","slug":"no-state-model-found-for-entity-meta-model-name-cb59fa","errorCode":null,"errorMessage":"No state model found for {entity._meta.model_name} when getting current state object","messagePattern":"No state model found for (.+?) when getting current state object","errorType":"exception","errorClass":"StateManagerError","httpStatus":null,"severity":"error","filePath":"label_studio/fsm/state_manager.py","lineNumber":208,"sourceCode":"            raise StateManagerError(f'Error getting current state: {e}') from e\n\n    @classmethod\n    def get_current_state_object(cls, entity: Model) -> BaseState:\n        \"\"\"\n        Get current state object with full audit information.\n\n        Args:\n            entity: The entity to get current state object for\n\n        Returns:\n            Latest BaseState instance\n\n        Raises:\n            StateManagerError: If no state model found\n        \"\"\"\n        state_model = get_state_model_for_entity(entity)\n        if not state_model:\n            raise StateManagerError(\n                f'No state model found for {entity._meta.model_name} when getting current state object'\n            )\n\n        return state_model.get_current_state(entity)\n\n    @classmethod\n    def transition_state(\n        cls,\n        entity: Model,\n        new_state: str,\n        transition_name: str = None,\n        user=None,\n        organization_id=None,\n        context: Dict[str, Any] = None,\n        reason: str = '',\n        force_state_record: bool = False,\n    ) -> bool:\n        \"\"\"","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/fsm/state_manager.py#L190-L226","documentation":"get_current_state_object resolves the entity's state model from the registry and, if absent, raises StateManagerError noting no state model was found 'when getting current state object'. Unlike get_current_state_value this variant returns the full BaseState instance with audit information, but it depends on exactly the same registration. Callers include transition execution and get_available_transitions.","triggerScenarios":"Calling get_current_state_object for an entity whose model has no registered state model; also hit indirectly when execute_transition_with_state_manager or get_available_transitions run against an unregistered entity type.","commonSituations":"Invoking transitions/available-transition listing on models not wired into the FSM registry; running in an environment (LSE missing, feature flag off at registration time) where registration code never executed; typos in registration key vs. entity._meta.model_name.","solutions":["Register the entity's state model in the registry (state_model_registry.register) before querying state objects.","Pre-check with get_state_model_for_entity(entity) and skip/branch when None for non-FSM entities.","Confirm the registration decorator/module is imported at app startup (check Django app config).","Verify model_name matches: registry keys derive from _meta.model_name; renames of the model must be reflected in registration."],"exampleFix":"// before\nstate_obj = StateManager.get_current_state_object(annotation)  # raises for unregistered model\n\n// after\nif get_state_model_for_entity(annotation):\n    state_obj = StateManager.get_current_state_object(annotation)\nelse:\n    state_obj = None","handlingStrategy":"type-guard","validationCode":"from fsm.registry import get_state_model_for_entity\n\nif get_state_model_for_entity(entity) is None:\n    return None  # no state object for unregistered entities","typeGuard":"def has_state_model(entity) -> bool:\n    from fsm.registry import get_state_model_for_entity\n    return get_state_model_for_entity(entity) is not None","tryCatchPattern":"from fsm.state_manager import StateManagerError\ntry:\n    state_obj = StateManager.get_current_state_object(entity)\nexcept StateManagerError as e:\n    if 'No state model found' in str(e):\n        state_obj = None\n    else:\n        raise","preventionTips":["Verify registry membership before requesting state objects or available transitions","Ensure registration modules are imported via Django app configs at startup","Treat non-FSM entities as a distinct code path instead of calling state APIs on them"],"tags":["fsm","registry","state-manager","django"],"backgroundTag":"unregistered-entity-state-model","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}