sgl-project/sglang · error · ValueError

canonical request missing {key!r}

Error message

canonical request missing {key!r}

What it means

minimax_h3_resolve_plan validates the canonical request dict before building a ResolvedPlan and requires the keys 'schema', 'task', 'prompt', 'conditions', and 'target' to all be present. If any is absent, it raises ValueError telling you which key is missing. This is a fail-closed schema check so downstream stages never see a partial plan.

Source

Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/resolved_plan.py:277

    """Canonical request (already validated) -> ResolvedPlan."""
    if not isinstance(canonical, Mapping):
        raise ValueError("canonical request must be a mapping")
    allowed_keys = {
        "schema",
        "task",
        "prompt",
        "conditions",
        "target",
        "seed",
        "flow_shift",
        "audio_flow_shift",
    }
    unknown = set(canonical) - allowed_keys
    if unknown:
        raise ValueError(f"canonical request has unknown fields: {sorted(unknown)}")
    for key in ("schema", "task", "prompt", "conditions", "target"):
        if key not in canonical:
            raise ValueError(f"canonical request missing {key!r}")
    profile = minimax_h3_task_profile(str(canonical["task"]))
    conditions = canonical["conditions"]
    keyframe_conditions = (
        [
            condition
            for condition in conditions
            if isinstance(condition, Mapping) and condition.get("role") == "keyframe"
        ]
        if isinstance(conditions, (list, tuple))
        else []
    )
    if profile.task == "fl2va" or keyframe_conditions:
        signatures = (
            [
                (
                    condition.get("type"),
                    condition.get("role"),
                    condition.get("frame_index"),

View on GitHub (pinned to 0132848349)

Solutions

  1. Add the missing key reported in the message to the canonical request dict
  2. Validate/serialize the request against the expected schema (the allowed key set enforced just above) before calling resolve
  3. Regenerate the canonical request from the batch adapter instead of hand-writing it

Example fix

# before
plan = minimax_h3_resolve_plan({"schema": "minimax_h3", "task": "fl2va", "prompt": "...", "conditions": []})
# after
plan = minimax_h3_resolve_plan({"schema": "minimax_h3", "task": "fl2va", "prompt": "...", "conditions": [], "target": {...}})
Defensive patterns

Strategy: validation

Validate before calling

required = {"schema","task","prompt","conditions","target"}
missing = required - set(canonical)
assert not missing, f"missing {missing}"

Type guard

def is_complete_canonical(c: Mapping) -> bool:
    return set(c) >= {"schema","task","prompt","conditions","target"}

Prevention

When it happens

Trigger: Calling minimax_h3_resolve_plan / minimax_h3_plan_from_batch with a canonical dict that omitted one of the five required keys (e.g. forgot 'target' or 'conditions').

Common situations: Building a minimax_h3 canonical request by hand or transforming one from another format and dropping a field; upstream payload changes after a library upgrade that renamed/removed keys.

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 sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/537516ea98161930. Report an issue: GitHub.