HumanSignal/label-studio · error · ValueError
Failed to create {transition_class.__name__}: {e}
Error message
Failed to create {transition_class.__name__}: {e} What it means
create_transition_from_dict instantiates a transition class from a dict of data and re-raises any construction failure as ValueError with the class name and original error. It is a validation wrapper: the transition's __init__ rejected the supplied data.
Source
Thrown at label_studio/fsm/transition_utils.py:126
"""
Create a transition instance from a dictionary of data.
This handles Pydantic validation and provides clear error messages.
Args:
transition_class: The transition class to instantiate
data: Dictionary of transition data
Returns:
Validated transition instance
Raises:
ValueError: If data validation fails
"""
try:
return transition_class(**data)
except Exception as e:
raise ValueError(f'Failed to create {transition_class.__name__}: {e}')
def get_transition_schema(transition_class: Type[BaseTransition]) -> Dict[str, Any]:
"""
Get the JSON schema for a transition class.
Useful for generating API documentation or frontend forms.
Args:
transition_class: The transition class
Returns:
JSON schema dictionary
"""
return transition_class.model_json_schema()
def validate_transition_data(transition_class: Type[BaseTransition], data: Dict[str, Any]) -> Dict[str, List[str]]:View on GitHub (pinned to 0b49e9b539)
Solutions
- Read the chained message '{e}' to see which field failed validation.
- Validate the payload against get_transition_schema(transition_class) before constructing.
- Fix the data dict to include all required fields with correct types.
- On the caller side, catch ValueError and return a 400-style validation error to the API client.
Example fix
// before
transition = create_transition_from_dict(StartTaskTransition, {"foo": 1})
// after
schema = get_transition_schema(StartTaskTransition)
validate_against_schema(schema, data) # raises clear field errors first
transition = create_transition_from_dict(StartTaskTransition, {"task_id": 1, "assigned_user_id": 2}) Defensive patterns
Strategy: validation
Validate before calling
schema = get_transition_schema(StartTaskTransition) # validate payload against schema before construction jsonschema.validate(instance=data, schema=schema)
Type guard
def is_valid_transition_payload(cls, data: dict) -> bool:
try:
cls(**data)
return True
except Exception:
return False Try / catch
try:
t = create_transition_from_dict(StartTaskTransition, data)
except ValueError as e:
return Response({'detail': str(e)}, status=400) Prevention
- Validate API payloads against get_transition_schema before constructing transitions.
- Use typed/serialized DTOs at boundaries so required fields can't silently vanish.
- Unit-test each transition class construction with minimal and full payloads.
When it happens
Trigger: Calling create_transition_from_dict(TransitionClass, data) where data is missing required fields, has wrong types, or fails pydantic-style validation in BaseTransition.__init__.
Common situations: Deserialized JSON payloads missing required keys; string/None values where ints or enums are expected; extra/unknown keys rejected by strict models; API clients sending malformed transition payloads.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- transition_name: Unknown transition for this entity
- transition_name: Transition is auto-triggered and cannot be
- detail: {pydantic validation message}
- detail: {transition validation message}
- Transition validation failed for {self.transition_name}
AI-assisted analysis of HumanSignal/label-studio@0b49e9b539 (2026-08-29).
Data as JSON: /api/errors/a4d18c42c7f3c971.
Report an issue: GitHub.