{"record":{"id":"0490ed10da6500c0","repo":"sgl-project/sglang","slug":"cannot-parse-boolean-batching-config-value-value","errorCode":null,"errorMessage":"cannot parse boolean batching config value: {value!r}","messagePattern":"cannot parse boolean batching config value: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/managers/dynamic_batch_admission.py","lineNumber":349,"sourceCode":"\ndef _optional_float(value: Any) -> float | None:\n    if value is None:\n        return None\n    return float(value)\n\n\ndef _optional_bool(value: Any) -> bool | None:\n    if value is None:\n        return None\n    if isinstance(value, bool):\n        return value\n    if isinstance(value, str):\n        lowered = value.strip().lower()\n        if lowered in (\"1\", \"true\", \"yes\", \"y\", \"on\"):\n            return True\n        if lowered in (\"0\", \"false\", \"no\", \"n\", \"off\"):\n            return False\n    raise ValueError(f\"cannot parse boolean batching config value: {value!r}\")\n","sourceCodeStart":331,"sourceCodeEnd":350,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/managers/dynamic_batch_admission.py#L331-L350","documentation":"Boolean-typed optional fields in a rule accept bools and the strings 1/true/yes/y/on and 0/false/no/n/off (case-insensitive). _optional_bool raises when the value is any other string or an unparseable type.","triggerScenarios":"A rule field parsed via _optional_bool with a value like \"enabled\", \"maybe\", or an int like 2 (non-bool, non-recognized string).","commonSituations":"Config generated from YAML where booleans were quoted arbitrarily; env-var-style values like \"TRUE \" handled fine but custom words like \"enable\" are not.","solutions":["Use a real JSON boolean true/false","If a string is required, use one of: 1/true/yes/y/on or 0/false/no/n/off"],"exampleFix":"// before\n{\"model\": \"x\", \"max_batch_size\": 4, \"some_flag\": \"enabled\"}\n// after\n{\"model\": \"x\", \"max_batch_size\": 4, \"some_flag\": true}","handlingStrategy":"validation","validationCode":"BOOL_STR = {\"1\",\"true\",\"yes\",\"y\",\"on\",\"0\",\"false\",\"no\",\"n\",\"off\"}\ndef ok_bool(v):\n    return isinstance(v, bool) or (isinstance(v, str) and v.strip().lower() in BOOL_STR)","typeGuard":"def is_parseable_bool(v) -> bool:\n    return isinstance(v, bool) or (isinstance(v, str) and v.strip().lower() in {\"1\",\"true\",\"yes\",\"y\",\"on\",\"0\",\"false\",\"no\",\"n\",\"off\"})","tryCatchPattern":null,"preventionTips":["Prefer real JSON booleans over string forms in config files"],"tags":["config","batching","boolean-parsing","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}