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 What it means
StateManager.get_current_state_value looks up the entity's state model via the registry (get_state_model_for_entity). When no state model has been registered for the entity's Django model, it raises StateManagerError naming the model. StateManager can only read current state through a registered state model's get_current_state_value, so an unregistered entity is unsupported rather than simply 'stateless'.
Source
Thrown at label_studio/fsm/state_manager.py:158
# Try cache first
cached_state = fsm_cache.get(cache_key)
if cached_state is not None:
logger.info(
'FSM: Cache hit',
extra={
'event': 'fsm.cache_hit',
'entity_type': entity._meta.label_lower,
'entity_id': entity.pk,
'organization_id': CurrentContext.get_organization_id(),
'state': cached_state,
},
)
return cached_state
# Query database using state model registry
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')
try:
current_state = state_model.get_current_state_value(entity)
# Cache result
if current_state is not None:
fsm_cache.set(cache_key, current_state, cls.CACHE_TTL)
logger.info(
'FSM: Cache miss',
extra={
'event': 'fsm.cache_miss',
'entity_type': entity._meta.label_lower,
'entity_id': entity.pk,
'organization_id': CurrentContext.get_organization_id(),
},
)
return current_stateView on GitHub (pinned to 0b49e9b539)
Solutions
- Register a state model for the entity in fsm/registry (state_model_registry.register) or check the entity against state_model_registry.get_all_models() before calling.
- Verify the entity type is actually FSM-managed; guard calls with a registry lookup for entity._meta.model_name.
- Check app/import ordering so registrations run before any StateManager call.
- If on Label Studio Open Source, confirm the entity's state model isn't Enterprise-only (LSE) — install/enable the component that registers it.
Example fix
// before
state = StateManager.get_current_state_value(task) # raises: No state model found for task
// after
from fsm.registry import get_state_model_for_entity
if get_state_model_for_entity(task) is not None:
state = StateManager.get_current_state_value(task)
else:
state = None # entity is not FSM-managed 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:
# entity is not FSM-managed; skip state lookup
... Type guard
def is_fsm_managed(entity) -> bool:
from fsm.registry import get_state_model_for_entity
try:
return get_state_model_for_entity(entity) is not None
except Exception:
return False Try / catch
from fsm.state_manager import StateManagerError
try:
state = StateManager.get_current_state_value(entity)
except StateManagerError as e:
if 'No state model found' in str(e):
state = None # entity has no FSM support
else:
raise Prevention
- Check the registry before calling StateManager for any entity type
- Register state models at app startup so they exist before any lookup
- Keep registry keys in sync with model renames (_meta.model_name)
When it happens
Trigger: Calling get_current_state_value (directly or via transition_state/warm_cache) with an entity whose model was never registered via the state-model registry — e.g., a model without FSM registration, a proxy/swapped model whose label doesn't match the registration key, or code running before registry population (imports/app-init order).
Common situations: Adding FSM calls to a new model but forgetting the registry.register decorator; model swaps or migrations changing model_name; enterprise/community version skew where the state model registration lives in a package not installed; calling transitions in management commands before Django app registry is ready.
Related errors
- No state model found for {entity._meta.model_name} when gett
- No state model found for {entity._meta.model_name} when tran
- No state model registered for {entity._meta.model_name} when
- Invalid entity name: {entity_name}
- transition_name: Unknown transition for this entity
AI-assisted analysis of HumanSignal/label-studio@0b49e9b539 (2026-08-29).
Data as JSON: /api/errors/33ba1bbd445c7063.
Report an issue: GitHub.