{"record":{"id":"a4d18c42c7f3c971","repo":"HumanSignal/label-studio","slug":"failed-to-create-transition-class-name-e","errorCode":null,"errorMessage":"Failed to create {transition_class.__name__}: {e}","messagePattern":"Failed to create (.+?): (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"label_studio/fsm/transition_utils.py","lineNumber":126,"sourceCode":"    \"\"\"\n    Create a transition instance from a dictionary of data.\n\n    This handles Pydantic validation and provides clear error messages.\n\n    Args:\n        transition_class: The transition class to instantiate\n        data: Dictionary of transition data\n\n    Returns:\n        Validated transition instance\n\n    Raises:\n        ValueError: If data validation fails\n    \"\"\"\n    try:\n        return transition_class(**data)\n    except Exception as e:\n        raise ValueError(f'Failed to create {transition_class.__name__}: {e}')\n\n\ndef get_transition_schema(transition_class: Type[BaseTransition]) -> Dict[str, Any]:\n    \"\"\"\n    Get the JSON schema for a transition class.\n\n    Useful for generating API documentation or frontend forms.\n\n    Args:\n        transition_class: The transition class\n\n    Returns:\n        JSON schema dictionary\n    \"\"\"\n    return transition_class.model_json_schema()\n\n\ndef validate_transition_data(transition_class: Type[BaseTransition], data: Dict[str, Any]) -> Dict[str, List[str]]:","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/fsm/transition_utils.py#L108-L144","documentation":"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.","triggerScenarios":"Calling create_transition_from_dict(TransitionClass, data) where data is missing required fields, has wrong types, or fails pydantic-style validation in BaseTransition.__init__.","commonSituations":"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.","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."],"exampleFix":"// before\ntransition = create_transition_from_dict(StartTaskTransition, {\"foo\": 1})\n// after\nschema = get_transition_schema(StartTaskTransition)\nvalidate_against_schema(schema, data)  # raises clear field errors first\ntransition = create_transition_from_dict(StartTaskTransition, {\"task_id\": 1, \"assigned_user_id\": 2})","handlingStrategy":"validation","validationCode":"schema = get_transition_schema(StartTaskTransition)\n# validate payload against schema before construction\njsonschema.validate(instance=data, schema=schema)","typeGuard":"def is_valid_transition_payload(cls, data: dict) -> bool:\n    try:\n        cls(**data)\n        return True\n    except Exception:\n        return False","tryCatchPattern":"try:\n    t = create_transition_from_dict(StartTaskTransition, data)\nexcept ValueError as e:\n    return Response({'detail': str(e)}, status=400)","preventionTips":["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."],"tags":["fsm","validation","data-mapping"],"backgroundTag":"schema-validation-failed","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}