{"record":{"id":"d92c59c3aef1b205","repo":"HKUDS/DeepTutor","slug":"invalid-label-config-details","errorCode":null,"errorMessage":"Invalid {label} config: {details}","messagePattern":"Invalid (.+?) config: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"deeptutor/runtime/request_contracts.py","lineNumber":99,"sourceCode":"        cleaned.pop(key, None)\n    return cleaned\n\n\ndef _validate_model(\n    model_type: type[BaseModel],\n    raw_config: dict[str, Any] | None,\n    *,\n    label: str,\n) -> BaseModel:\n    cleaned = _clean_public_config(raw_config)\n    try:\n        return model_type.model_validate(cleaned)\n    except ValidationError as exc:\n        details = \"; \".join(\n            f\"{'.'.join(str(part) for part in error['loc'])}: {error['msg']}\"\n            for error in exc.errors()\n        )\n        raise ValueError(f\"Invalid {label} config: {details}\") from exc\n\n\ndef validate_chat_request_config(raw_config: dict[str, Any] | None) -> ChatRequestConfig:\n    return _validate_model(ChatRequestConfig, raw_config, label=\"chat\")\n\n\ndef validate_deep_solve_request_config(\n    raw_config: dict[str, Any] | None,\n) -> DeepSolveRequestConfig:\n    return _validate_model(DeepSolveRequestConfig, raw_config, label=\"deep solve\")\n\n\ndef validate_deep_question_request_config(\n    raw_config: dict[str, Any] | None,\n) -> DeepQuestionRequestConfig:\n    return _validate_model(DeepQuestionRequestConfig, raw_config, label=\"deep question\")\n\n","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/runtime/request_contracts.py#L81-L117","documentation":"_validate_model runs Pydantic v2 model_validate on the cleaned capability config and converts ValidationError into a single-line ValueError listing every field path and message (e.g. 'render_mode: Input should be ...'). label names the capability (chat, deep_solve, deep_question, visualize).","triggerScenarios":"Submitting a valid JSON object as config for one of the four capabilities, but with a field that fails the capability's Pydantic schema: unknown-typed values, wrong enum, out-of-range numbers, or non-coercible types.","commonSituations":"Sending visualize config with an invalid render_mode; sending a string where a number is expected; passing extra runtime-only keys is fine (they're stripped), but wrong-typed known fields fail; version mismatches after a schema change adds required fields.","solutions":["Read the '{label} config: {details}' message — it names the exact field path and reason; fix that field","Check the corresponding Pydantic model (e.g. VisualizeRequestConfig) in deeptutor/runtime/request_contracts.py for allowed fields, enums, and ranges","Validate your payload client-side against the same schema before sending","Update deeptutor if the server schema changed and your client is sending the old shape"],"exampleFix":"# before\n{\"config\": {\"render_mode\": \"mp4\"}}\n# after\n{\"config\": {\"render_mode\": \"manim_video\"}}","handlingStrategy":"validation","validationCode":"from deeptutor.runtime.request_contracts import validate_visualize_request_config\ntry:\n    validated = validate_visualize_request_config(raw)\nexcept ValueError as e:\n    print(e)  # lists field paths — fix before sending","typeGuard":"import pydantic\nfrom deeptutor.runtime.request_contracts import VisualizeRequestConfig\ndef is_valid_visualize_config(cfg: dict) -> bool:\n    try:\n        VisualizeRequestConfig.model_validate({k: v for k, v in cfg.items()})\n        return True\n    except pydantic.ValidationError:\n        return False","tryCatchPattern":"try:\n    send_request({\"config\": cfg})\nexcept ValueError as e:\n    if str(e).startswith(\"Invalid visualize config:\"):\n        show_field_errors_to_user(str(e))","preventionTips":["Share the Pydantic models between client and server via the SDK","Pin deeptutor versions so schema changes surface in upgrade notes","Unit-test payloads against the validate_*_request_config helpers before shipping clients"],"tags":["pydantic","schema-validation","request-validation","api"],"backgroundTag":"schema-validation-failed","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}