{"record":{"id":"10a055fc173f17e4","repo":"sgl-project/sglang","slug":"override-server-args-unknown-serverargs-field-s","errorCode":null,"errorMessage":"override_server_args: unknown ServerArgs field(s): {sorted(unknown)}","messagePattern":"override_server_args: unknown ServerArgs field\\(s\\): (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/runtime_context.py","lineNumber":1060,"sourceCode":"        self._prev_bags = ctx._config_bags\n        self._prev_overrides_log = ctx._overrides_log\n        self._prev_publish_role = ctx._publish_role\n        self._prev_parallel_config = ctx.parallel._config\n        self._prev_capture = ctx.flags.capture.enable_torch_compile\n        from sglang.srt.arg_groups.overrides import (\n            _apply_fields,\n            declare_late_resolution,\n        )\n\n        server_args = ServerArgs(model_path=\"dummy\")\n        server_args.resolve_once()\n        # Underscore names seed private property caches (the strict guard\n        # exempts them); everything else must be a real config field.\n        unknown = {name for name in self._fields if not name.startswith(\"_\")} - set(\n            type(server_args).__dataclass_fields__\n        )\n        if unknown:\n            raise ValueError(\n                f\"override_server_args: unknown ServerArgs field(s): {sorted(unknown)}\"\n            )\n        # Declared so the projection sees it; late, because the record is\n        # resolved already and not yet published.\n        # Underscore names are not fields at all (they seed private property\n        # caches), so they stay a direct write.\n        declared = {\n            name: value for name, value in self._fields.items() if name[0] != \"_\"\n        }\n        if declared:\n            declare_late_resolution(server_args, \"override_server_args\", **declared)\n        # This hook stands in for a launch: the caller's values are both what\n        # the operator passed and what resolution decided, so they go on the\n        # record as well as into the stash. Production late resolution declares\n        # only -- there the record stays the operator's input.\n        _apply_fields(server_args, self._fields)\n        ctx.set_server_args(server_args)\n        self._installed = True","sourceCodeStart":1042,"sourceCodeEnd":1078,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/runtime_context.py#L1042-L1078","documentation":"The override_server_args context manager validates that every non-underscore field it was given is a real ServerArgs dataclass field. Unknown names are rejected with this ValueError listing the sorted offending names. Underscore-prefixed names are exempt because they seed private property caches, not config fields.","triggerScenarios":"with ctx.override_server_args(tp_size=4): where 'tp_size' is not a ServerArgs field (real name is tensor_parallel_size); passing an obsolete field name after an upgrade renamed it; passing arbitrary kwargs the API does not accept.","commonSituations":"Typos or outdated field names in tests or override call sites after ServerArgs fields were renamed; copy-pasting kwargs from a different CLI/config schema into the override.","solutions":["Use the exact ServerArgs dataclass field name (check ServerArgs.__dataclass_fields__)","If the field was renamed upstream, update the call site to the new name","Only use underscore-prefixed names if you intentionally seed a private property cache"],"exampleFix":"# before\nwith ctx.override_server_args(tp_size=4):\n    ...\n# after\nwith ctx.override_server_args(tensor_parallel_size=4):\n    ...","handlingStrategy":"validation","validationCode":"from dataclasses import fields\nfrom sglang.srt.server_args import ServerArgs\nvalid = {f.name for f in fields(ServerArgs)}\nunknown = {k for k in overrides if not k.startswith(\"_\")} - valid\nif unknown:\n    raise ValueError(f\"bad override keys: {sorted(unknown)}\")\nwith ctx.override_server_args(**overrides):\n    ...","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize override construction in one helper that validates against ServerArgs fields","After ServerArgs renames, run a test/lint pass over override_server_args call sites"],"tags":["config","override","typo","sglang"],"backgroundTag":"unknown-config-field","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}