{"record":{"id":"a99e44b9911925f3","repo":"vllm-project/vllm","slug":"disable-any-whitespace-is-only-supported-for-xgram","errorCode":null,"errorMessage":"disable_any_whitespace is only supported for xgrammar and guidance backends.","messagePattern":"disable_any_whitespace is only supported for xgrammar and guidance backends\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"vllm/config/structured_outputs.py","lineNumber":65,"sourceCode":"        ensure that it is included in the factors list if\n        it affects the computation graph.\n\n        Provide a hash that uniquely identifies all the configs\n        that affect the structure of the computation\n        graph from input ids/embeddings to the final hidden states,\n        excluding anything before input ids/embeddings and after\n        the final hidden states.\n        \"\"\"\n        # no factors to consider.\n        # this config will not affect the computation graph.\n        factors: list[Any] = []\n        hash_str = safe_hash(str(factors).encode(), usedforsecurity=False).hexdigest()\n        return hash_str\n\n    @model_validator(mode=\"after\")\n    def _validate_structured_output_config(self) -> Self:\n        if self.disable_any_whitespace and self.backend not in (\"xgrammar\", \"guidance\"):\n            raise ValueError(\n                \"disable_any_whitespace is only supported for \"\n                \"xgrammar and guidance backends.\"\n            )\n        if self.disable_additional_properties and self.backend != \"guidance\":\n            raise ValueError(\n                \"disable_additional_properties is only supported \"\n                \"for the guidance backend.\"\n            )\n        return self\n","sourceCodeStart":47,"sourceCodeEnd":75,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/config/structured_outputs.py#L47-L75","documentation":"StructuredOutputsConfig validates that disable_any_whitespace is only combined with the 'xgrammar' or 'guidance' structured-output backends. The flag instructs the grammar engine to forbid any whitespace in the generated output, and only those two backends implement that constraint in their grammar compilation. Requesting it with 'outlines', 'lm-format-enforcer', or no backend (auto-resolved elsewhere) fails fast at config validation.","triggerScenarios":"Setting --structured-outputs-config '{\"disable_any_whitespace\": true, \"backend\": \"outlines\"}' (or leaving backend to auto-resolve to an unsupported engine), or setting disable_any_whitespace=True in StructuredOutputsConfig while the effective backend is not xgrammar/guidance.","commonSituations":"Tightening JSON schema conformance (no whitespace in numbers/strings) for strict downstream parsers and assuming all grammar backends support it; switching backend for performance while keeping the whitespace flag; new flag adopted from docs without checking backend compatibility matrix.","solutions":["Set backend='xgrammar' or backend='guidance' in the structured outputs config","Remove disable_any_whitespace (accept default whitespace-tolerant behavior) if you must keep another backend","Post-validate whitespace on the application side if you cannot change the backend"],"exampleFix":"# before\nstructured_outputs_config = {\"backend\": \"outlines\", \"disable_any_whitespace\": True}\n# after\nstructured_outputs_config = {\"backend\": \"xgrammar\", \"disable_any_whitespace\": True}","handlingStrategy":"validation","validationCode":"cfg = {\"backend\": \"outlines\", \"disable_any_whitespace\": True}\nassert not cfg.get(\"disable_any_whitespace\") or cfg.get(\"backend\") in (\"xgrammar\", \"guidance\"), \\\n    \"disable_any_whitespace needs xgrammar or guidance\"","typeGuard":"def whitespace_flag_ok(cfg: dict) -> bool:\n    return not cfg.get(\"disable_any_whitespace\") or cfg.get(\"backend\") in (\"xgrammar\", \"guidance\")","tryCatchPattern":null,"preventionTips":["Pair whitespace-strictness flags with an explicit backend, never auto-resolve","Maintain a per-backend feature matrix for structured-output options in your config library"],"tags":["structured-output","grammar","config","validation"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}