HumanSignal/label-studio · error · StateManagerError

No state model found for {entity._meta.model_name} when gett

Error message

No state model found for {entity._meta.model_name} when getting current state object

What it means

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.

Source

Thrown at label_studio/fsm/state_manager.py:208

            raise StateManagerError(f'Error getting current state: {e}') from e

    @classmethod
    def get_current_state_object(cls, entity: Model) -> BaseState:
        """
        Get current state object with full audit information.

        Args:
            entity: The entity to get current state object for

        Returns:
            Latest BaseState instance

        Raises:
            StateManagerError: If no state model found
        """
        state_model = get_state_model_for_entity(entity)
        if not state_model:
            raise StateManagerError(
                f'No state model found for {entity._meta.model_name} when getting current state object'
            )

        return state_model.get_current_state(entity)

    @classmethod
    def transition_state(
        cls,
        entity: Model,
        new_state: str,
        transition_name: str = None,
        user=None,
        organization_id=None,
        context: Dict[str, Any] = None,
        reason: str = '',
        force_state_record: bool = False,
    ) -> bool:
        """

View on GitHub (pinned to 0b49e9b539)

Solutions

  1. Register the entity's state model in the registry (state_model_registry.register) before querying state objects.
  2. Pre-check with get_state_model_for_entity(entity) and skip/branch when None for non-FSM entities.
  3. Confirm the registration decorator/module is imported at app startup (check Django app config).
  4. Verify model_name matches: registry keys derive from _meta.model_name; renames of the model must be reflected in registration.

Example fix

// before
state_obj = StateManager.get_current_state_object(annotation)  # raises for unregistered model

// after
if get_state_model_for_entity(annotation):
    state_obj = StateManager.get_current_state_object(annotation)
else:
    state_obj = None
Defensive patterns

Strategy: type-guard

Validate before calling

from fsm.registry import get_state_model_for_entity

if get_state_model_for_entity(entity) is None:
    return None  # no state object for unregistered entities

Type guard

def has_state_model(entity) -> bool:
    from fsm.registry import get_state_model_for_entity
    return get_state_model_for_entity(entity) is not None

Try / catch

from fsm.state_manager import StateManagerError
try:
    state_obj = StateManager.get_current_state_object(entity)
except StateManagerError as e:
    if 'No state model found' in str(e):
        state_obj = None
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of HumanSignal/label-studio@0b49e9b539 (2026-08-29). Data as JSON: /api/errors/cb59facfd986bf9c. Report an issue: GitHub.