{"record":{"id":"a6d83943eccc32fa","repo":"sgl-project/sglang","slug":"invalid-component-residency-assignment-raw-selec","errorCode":null,"errorMessage":"Invalid component residency assignment: {raw_selector!r}={raw_mode!r}","messagePattern":"Invalid component residency assignment: (.+?)=(.+?)","errorType":"validation","errorClass":"ComponentResidencyError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/managers/memory_managers/component_residency.py","lineNumber":84,"sourceCode":"                    f\"Invalid component residency assignment: {value!r}\"\n                )\n            for assignment in value.split(\",\"):\n                assignment = assignment.strip()\n                if not assignment:\n                    continue\n                if \"=\" not in assignment:\n                    raise ComponentResidencyError(\n                        \"Component residency must use COMPONENT=MODE, got \"\n                        f\"{assignment!r}\"\n                    )\n                selector, mode = assignment.split(\"=\", 1)\n                parsed_entries.append((selector, mode))\n        entries = parsed_entries\n\n    normalized: dict[str, str] = {}\n    for raw_selector, raw_mode in entries:\n        if not isinstance(raw_selector, str) or not isinstance(raw_mode, str):\n            raise ComponentResidencyError(\n                \"Invalid component residency assignment: \"\n                f\"{raw_selector!r}={raw_mode!r}\"\n            )\n        selector = raw_selector.strip().replace(\"-\", \"_\").lower()\n        mode = raw_mode.strip().replace(\"_\", \"-\").lower()\n        if not selector:\n            raise ComponentResidencyError(\n                \"Component residency selector cannot be empty\"\n            )\n        if mode not in COMPONENT_RESIDENCY_MODES:\n            expected = \", \".join(sorted(COMPONENT_RESIDENCY_MODES))\n            raise ComponentResidencyError(\n                f\"Invalid component residency mode {raw_mode!r} for \"\n                f\"{selector!r}; expected one of: {expected}\"\n            )\n        normalized[selector] = mode\n\n    return normalized or None","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/managers/memory_managers/component_residency.py#L66-L102","documentation":"When assignments are given as a dict, both the selector key and the mode value must be strings; non-string keys or values (e.g. int keys from JSON with numeric component ids, or None values) raise ComponentResidencyError.","triggerScenarios":"Passing a dict like {4096: \"cpu\"} or {\"vit\": None} to normalize_component_residency / the _normalize_component_residency entry point.","commonSituations":"Programmatically building the mapping from data that wasn't coerced to strings (numeric model/component IDs, optional fields left as None).","solutions":["Coerce all keys and values to strings before building the dict","Drop entries whose mode is None instead of storing None"],"exampleFix":"# before\nresidency = {4096: \"cpu\", \"vit\": None}\n# after\nresidency = {\"4096\": \"cpu\"}","handlingStrategy":"type-guard","validationCode":"if any(not isinstance(k, str) or not isinstance(v, str) for k, v in d.items()):\n    raise SystemExit(\"residency dict keys and values must be strings\")","typeGuard":"def is_str_str_dict(d) -> bool:\n    return all(isinstance(k, str) and isinstance(v, str) for k, v in d.items())","tryCatchPattern":null,"preventionTips":["Coerce parsed keys/values to str; drop None modes before building the dict"],"tags":["config","component-residency","type-error","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}