HKUDS/DeepTutor · error · ValueError

Invalid {label} config: {details}

Error message

Invalid {label} config: {details}

What it means

_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).

Source

Thrown at deeptutor/runtime/request_contracts.py:99

        cleaned.pop(key, None)
    return cleaned


def _validate_model(
    model_type: type[BaseModel],
    raw_config: dict[str, Any] | None,
    *,
    label: str,
) -> BaseModel:
    cleaned = _clean_public_config(raw_config)
    try:
        return model_type.model_validate(cleaned)
    except ValidationError as exc:
        details = "; ".join(
            f"{'.'.join(str(part) for part in error['loc'])}: {error['msg']}"
            for error in exc.errors()
        )
        raise ValueError(f"Invalid {label} config: {details}") from exc


def validate_chat_request_config(raw_config: dict[str, Any] | None) -> ChatRequestConfig:
    return _validate_model(ChatRequestConfig, raw_config, label="chat")


def validate_deep_solve_request_config(
    raw_config: dict[str, Any] | None,
) -> DeepSolveRequestConfig:
    return _validate_model(DeepSolveRequestConfig, raw_config, label="deep solve")


def validate_deep_question_request_config(
    raw_config: dict[str, Any] | None,
) -> DeepQuestionRequestConfig:
    return _validate_model(DeepQuestionRequestConfig, raw_config, label="deep question")

View on GitHub (pinned to 3e82f13042)

Solutions

  1. Read the '{label} config: {details}' message — it names the exact field path and reason; fix that field
  2. Check the corresponding Pydantic model (e.g. VisualizeRequestConfig) in deeptutor/runtime/request_contracts.py for allowed fields, enums, and ranges
  3. Validate your payload client-side against the same schema before sending
  4. Update deeptutor if the server schema changed and your client is sending the old shape

Example fix

# before
{"config": {"render_mode": "mp4"}}
# after
{"config": {"render_mode": "manim_video"}}
Defensive patterns

Strategy: validation

Validate before calling

from deeptutor.runtime.request_contracts import validate_visualize_request_config
try:
    validated = validate_visualize_request_config(raw)
except ValueError as e:
    print(e)  # lists field paths — fix before sending

Type guard

import pydantic
from deeptutor.runtime.request_contracts import VisualizeRequestConfig
def is_valid_visualize_config(cfg: dict) -> bool:
    try:
        VisualizeRequestConfig.model_validate({k: v for k, v in cfg.items()})
        return True
    except pydantic.ValidationError:
        return False

Try / catch

try:
    send_request({"config": cfg})
except ValueError as e:
    if str(e).startswith("Invalid visualize config:"):
        show_field_errors_to_user(str(e))

Prevention

When it happens

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

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

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


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/d92c59c3aef1b205. Report an issue: GitHub.