{"record":{"id":"c082b5dd832b9e72","repo":"sgl-project/sglang","slug":"return-hidden-states-mode-must-be-one-of-none-l","errorCode":null,"errorMessage":"return_hidden_states_mode must be one of: None, 'last', or 'full'.","messagePattern":"return_hidden_states_mode must be one of: None, 'last', or 'full'\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/server_args.py","lineNumber":4007,"sourceCode":"        self._handle_debug_utils()\n\n        # Handle any other necessary validations.\n        self._handle_other_validations()\n\n        # Model-capability adjustments that legacy code applied at model-load\n        # time; last declarations of the resolution, mirroring that order.\n        self._handle_model_capability_adjustments()\n\n        # Validate after all batch-size declarations are visible.\n        self._validate_deepep_v2_speculative_draft()\n        self._validate_deepep_v2_dispatch_token_budget()\n\n        self._resolution_finished = True\n\n    def _handle_return_hidden_states_mode(self):\n        cfg = resolving_view(self)\n        if cfg.return_hidden_states_mode not in (None, \"last\", \"full\"):\n            raise ValueError(\n                \"return_hidden_states_mode must be one of: None, 'last', or 'full'.\"\n            )\n        if cfg.return_hidden_states_mode is None:\n            if cfg.enable_return_hidden_states:\n                self._declare(\n                    \"_handle_return_hidden_states_mode\",\n                    return_hidden_states_mode=\"full\",\n                )\n        else:\n            self._declare(\n                \"_handle_return_hidden_states_mode\",\n                enable_return_hidden_states=True,\n            )\n\n    def _handle_model_capability_adjustments(self):\n        cfg = resolving_view(self)\n        if parse_connector_type(cfg.model_path) == ConnectorType.INSTANCE:\n            return","sourceCodeStart":3989,"sourceCodeEnd":4025,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/server_args.py#L3989-L4025","documentation":"The return_hidden_states_mode field only accepts None, 'last', or 'full'. The resolution handler _handle_return_hidden_states_mode validates it early because downstream code branches on these exact values to collect hidden states for the request response.","triggerScenarios":"Passing --return-hidden-states-mode with a typo'd or unsupported value (e.g. \"all\", \"LAST\", \"last_token\", \"\") in the CLI, ServerArgs, or an env-derived config.","commonSituations":"Assuming 'all' is the plural form; case mismatch; passing an empty string instead of omitting the flag; copy-pasting from vLLM-style option names.","solutions":["Use one of: omit it (None), 'last', or 'full'.","If you only need the final layer's last-token hidden state, use 'last'; for all layers' hidden states use 'full'.","Check for typos/case in CLI or YAML configs."],"exampleFix":"# before\npython -m sglang.launch_server --model m --return-hidden-states-mode all\n# after\npython -m sglang.launch_server --model m --return-hidden-states-mode full","handlingStrategy":"validation","validationCode":"assert return_hidden_states_mode in (None, 'last', 'full'), return_hidden_states_mode","typeGuard":"def valid_hidden_states_mode(v) -> bool:\n    return v in (None, 'last', 'full')","tryCatchPattern":null,"preventionTips":["Pin enum values in one constants module instead of free-form CLI strings.","Dry-run ServerArgs construction in CI to catch bad option values early."],"tags":["server-args","hidden-states","cli-validation","sglang"],"backgroundTag":"invalid-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}