{"record":{"id":"40d22275bb3e5940","repo":"HumanSignal/label-studio","slug":"no-state-model-registered-for-entity-entity-name","errorCode":null,"errorMessage":"No state model registered for entity '{entity_name}'","messagePattern":"No state model registered for entity '(.+?)'","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"label_studio/fsm/transition_executor.py","lineNumber":86,"sourceCode":"        current_state=None,\n        target_state=None,  # Will be computed\n        organization_id=organization_id,\n    )\n\n    # Get target_state (can now use entity from context)\n    target_state = transition.get_target_state(minimal_context)\n    is_side_effect_only = target_state is None\n\n    if is_side_effect_only:\n        # No state model needed for side-effect only transitions\n        state_model = None\n        current_state_object = None\n        current_state = None\n    else:\n        # Get the state model for the entity\n        state_model = get_state_model_for_entity(entity)\n        if not state_model:\n            raise ValueError(f\"No state model registered for entity '{entity_name}'\")\n\n        # Get current state information directly from state model\n        current_state_object = state_model.get_current_state(entity)\n        current_state = current_state_object.state if current_state_object else None\n\n    # Build full transition context\n    context = TransitionContext(\n        entity=entity,\n        current_user=user,\n        current_state_object=current_state_object,\n        current_state=current_state,\n        target_state=target_state,\n        organization_id=organization_id,\n        **context_kwargs,\n    )\n\n    logger.info(\n        'Executing transition',","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/fsm/transition_executor.py#L68-L104","documentation":"During transition execution, the executor needs the entity's current state. If the entity is not a new/unpersisted record and get_state_model_for_entity(entity) returns None (no registered state model), it raises this ValueError.","triggerScenarios":"Executing a transition on a persisted entity whose model type has no FSM state model registered, while the entity IS in the registry branch of the code (i.e. not handled by the initial-state path).","commonSituations":"Forgetting register_state_model for the entity type; running transitions in tests with mock entities; registration code not executed because the app module wasn't loaded.","solutions":["Register a state model for the entity type before executing transitions.","Confirm the entity is a real saved Django model instance of the correct type.","Check that registry setup runs at startup (correct AppConfig / import).","For brand-new entities, verify they follow the expected 'no prior state' code path the executor supports."],"exampleFix":"// before\nexecute_transition(task, 'complete')  # TaskState not registered\n// after\nregister_state_model(Task, TaskState)\nexecute_transition(task, 'complete')","handlingStrategy":"validation","validationCode":"from label_studio.fsm.state_registry import get_state_model_for_entity\nassert get_state_model_for_entity(entity), f\"Register a state model for {entity._meta.model_name} before transitions\"","typeGuard":"def can_transition(entity) -> bool:\n    return get_state_model_for_entity(entity) is not None","tryCatchPattern":"try:\n    execute_transition(entity, name)\nexcept ValueError as e:\n    if f\"No state model registered\" in str(e):\n        register_state_model(type(entity), MyEntityState)\n        execute_transition(entity, name)\n    else:\n        raise","preventionTips":["Pair each model with its state model registration in the same app module.","Add integration tests that execute one transition per entity type.","Verify registry setup runs in all entrypoints (web, celery, management commands)."],"tags":["fsm","state-management","registry"],"backgroundTag":"unregistered-state-model","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}