{"record":{"id":"3fecb4f012c64168","repo":"sgl-project/sglang","slug":"cache-dit-params-secondary-must-be-a-dict-got","errorCode":null,"errorMessage":"cache_dit_params['secondary'] must be a dict, got {type(secondary).__name__}.","messagePattern":"cache_dit_params\\['secondary'\\] must be a dict, got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/cache/cache_dit_integration.py","lineNumber":239,"sourceCode":"\n\ndef resolve_cache_dit_request_overrides(raw: dict | None) -> dict:\n    \"\"\"Validate cache_dit_params and return a copy; unknown keys fail the request.\"\"\"\n    if raw is None:\n        return {}\n    if not isinstance(raw, dict):\n        raise ValueError(f\"cache_dit_params must be a dict, got {type(raw).__name__}.\")\n    unknown = set(raw) - CACHE_DIT_REQUEST_PARAM_KEYS\n    if unknown:\n        raise ValueError(\n            f\"Unknown cache_dit_params keys: {sorted(unknown)}. \"\n            f\"Valid keys: {sorted(CACHE_DIT_REQUEST_PARAM_KEYS)}.\"\n        )\n    overrides = dict(raw)\n    secondary = overrides.get(\"secondary\")\n    if secondary is not None:\n        if not isinstance(secondary, dict):\n            raise ValueError(\n                \"cache_dit_params['secondary'] must be a dict, got \"\n                f\"{type(secondary).__name__}.\"\n            )\n        unknown = set(secondary) - CACHE_DIT_REQUEST_KNOB_KEYS\n        if unknown:\n            raise ValueError(\n                f\"Unknown cache_dit_params['secondary'] keys: {sorted(unknown)}. \"\n                f\"Valid keys: {sorted(CACHE_DIT_REQUEST_KNOB_KEYS)}.\"\n            )\n        overrides[\"secondary\"] = dict(secondary)\n    return overrides\n\n\ndef cache_dit_overrides_key(overrides: dict) -> tuple:\n    \"\"\"Hashable snapshot of request overrides, for mount-change detection.\"\"\"\n\n    def _freeze(value):\n        if isinstance(value, dict):","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/cache/cache_dit_integration.py#L221-L257","documentation":"After the top-level key check, resolve_cache_dit_request_overrides inspects overrides.get('secondary'). If it is present (non-None) but not a dict, it raises this ValueError before ever looking at the knob keys.","triggerScenarios":"Sending cache_dit_params={\"secondary\": true} or {\"secondary\": 2} — the key is valid, but its value is not a JSON object.","commonSituations":"Clients treating 'secondary' as a boolean enable flag; shorthand/flattened encodings; schema drift between client models and the server's expected nested dict.","solutions":["Pass 'secondary' as an object of knob overrides (e.g. {\"secondary\": {\"cfg\": 1.0}}) or omit it entirely.","Fix the client schema that types 'secondary' as bool/number.","If you meant a top-level toggle, use one of the valid top-level keys from CACHE_DIT_REQUEST_PARAM_KEYS."],"exampleFix":"// before\nrequest(cache_dit_params={\"secondary\": true})\n// after\nrequest(cache_dit_params={\"secondary\": {\"cfg\": 1.0}})","handlingStrategy":"type-guard","validationCode":"sec = (cache_dit_params or {}).get(\"secondary\")\nif sec is not None and not isinstance(sec, dict):\n    raise TypeError(\"secondary must be a dict\")","typeGuard":"def has_valid_secondary(params: dict) -> bool:\n    sec = params.get(\"secondary\")\n    return sec is None or isinstance(sec, dict)","tryCatchPattern":"try:\n    client.generate(prompt, cache_dit_params=params)\nexcept ValueError as e:\n    if \"['secondary'] must be a dict\" in str(e):\n        params = {**params, \"secondary\": {}}\n        retry(client.generate, prompt, cache_dit_params=params)\n    raise","preventionTips":["Model 'secondary' as an object of knobs, never a flag.","Generate request payloads from typed dataclasses/Pydantic models.","Document the nested cache_dit_params shape in client SDKs."],"tags":["cache-dit","secondary-cache","type-error","request-validation"],"backgroundTag":"nested-config-type-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}