{"record":{"id":"c26a947b3e112f15","repo":"HumanSignal/label-studio","slug":"no-state-model-registered-for-entity-meta-model","errorCode":null,"errorMessage":"No state model registered for {entity._meta.model_name} when getting state history","messagePattern":"No state model registered for (.+?) when getting state history","errorType":"exception","errorClass":"StateManagerError","httpStatus":null,"severity":"error","filePath":"label_studio/fsm/state_manager.py","lineNumber":442,"sourceCode":"                },\n                exc_info=True,\n            )\n            raise StateManagerError(f'Failed to transition state: {e}') from e\n\n    @classmethod\n    def get_state_history(cls, entity: Model) -> QuerySet[BaseState]:\n        \"\"\"\n        Get complete state history for an entity.\n\n        Args:\n            entity: Entity to get history for\n\n        Returns:\n            QuerySet of state records ordered by most recent first\n        \"\"\"\n        state_model = get_state_model_for_entity(entity)\n        if not state_model:\n            raise StateManagerError(\n                f'No state model registered for {entity._meta.model_name} when getting state history'\n            )\n\n        return state_model.get_state_history(entity)\n\n    @classmethod\n    def get_states_in_time_range(\n        cls, entity: Model, start_time: datetime, end_time: Optional[datetime] = None\n    ) -> List[BaseState]:\n        \"\"\"\n        Get states within a time range using UUID7 time-based queries.\n\n        Args:\n            entity: Entity to get states for\n            start_time: Start of time range\n            end_time: End of time range (defaults to now)\n\n        Returns:","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/fsm/state_manager.py#L424-L460","documentation":"get_state_history looks up the entity's state model in the registry and raises StateManagerError when none is registered, using the 'state history' phrasing. The state history API endpoint (FSMEntityHistoryAPI.get_queryset) calls this, so requesting history for an entity type without a registered state model surfaces this error instead of an empty list.","triggerScenarios":"Calling StateManager.get_state_history(entity) for an unregistered model, or hitting GET /api/fsm/entities/{entity_type}/{entity_id}/history/ (after passing the endpoint's registry-list check) where the per-entity registry lookup still fails — e.g., registry populated differently at request time, or custom entity types added to permission_map but never registered as state models.","commonSituations":"Building a custom UI that lists history for entity types assumed FSM-managed; community edition serving history requests for enterprise-only registered state models; management scripts iterating over many model types including non-FSM ones.","solutions":["Only request history for entity types present in state_model_registry.get_all_models() (the endpoint's own list check).","Register a state model for the entity if it should have FSM history.","Guard script/API callers with get_state_model_for_entity(entity) and treat None as 'no history available'.","Verify deployment edition: if the state model is enterprise-only, ensure LSE components are installed and registration runs."],"exampleFix":"// before\nhistory = StateManager.get_state_history(my_custom_model_instance)  # raises: No state model registered\n\n// after\nif get_state_model_for_entity(my_custom_model_instance):\n    history = StateManager.get_state_history(my_custom_model_instance)\nelse:\n    history = BaseState.objects.none()","handlingStrategy":"type-guard","validationCode":"from fsm.registry import state_model_registry, get_state_model_for_entity\n\nentity_type_ok = entity._meta.model_name in state_model_registry.get_all_models()\nentity_ok = get_state_model_for_entity(entity) is not None\nif entity_type_ok and entity_ok:\n    history = StateManager.get_state_history(entity)","typeGuard":"def has_state_history(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 StateManager, StateManagerError\ntry:\n    qs = StateManager.get_state_history(entity)\nexcept StateManagerError as e:\n    if 'No state model registered' in str(e):\n        qs = BaseState.objects.none()\n    else:\n        raise","preventionTips":["Request history only for entity types in state_model_registry.get_all_models()","Register state models for any entity that should expose history via the API","Guard custom dashboards/scripts so non-FSM models return an empty history instead of erroring"],"tags":["fsm","registry","state-manager","api"],"backgroundTag":"unregistered-entity-state-model","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}