{"record":{"id":"9455993ee1762342","repo":"sgl-project/sglang","slug":"batching-config-rule-from-source-must-be-an-obje","errorCode":null,"errorMessage":"batching config rule from {source} must be an object, got {type(data).__name__}","messagePattern":"batching config rule from (.+?) must be an object, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/managers/dynamic_batch_admission.py","lineNumber":83,"sourceCode":"\n@dataclass(frozen=True)\nclass BatchingRule:\n    \"\"\"One user-provided batching admission rule loaded from batching config.\"\"\"\n\n    model: str | None = None\n    model_contains: str | None = None\n    resolution: str | None = None\n    device_memory_gb_min: float | None = None\n    device_memory_gb_max: float | None = None\n    offload: bool | None = None\n    max_batch_size: int = 1\n    max_cost: float | None = None\n    source: str = \"user\"\n\n    @classmethod\n    def from_dict(cls, data: dict[str, Any], *, source: str) -> BatchingRule:\n        if not isinstance(data, dict):\n            raise ValueError(\n                f\"batching config rule from {source} must be an object, \"\n                f\"got {type(data).__name__}\"\n            )\n        _validate_rule_keys(data, source=source)\n        if \"max_batch_size\" not in data:\n            raise ValueError(\"batching config rule requires max_batch_size\")\n\n        rule = cls(\n            model=_optional_str(data.get(\"model\")),\n            model_contains=_optional_str(data.get(\"model_contains\")),\n            resolution=_optional_str(data.get(\"resolution\")),\n            device_memory_gb_min=_optional_float(data.get(\"device_memory_gb_min\")),\n            device_memory_gb_max=_optional_float(data.get(\"device_memory_gb_max\")),\n            offload=_optional_bool(data.get(\"offload\")),\n            max_batch_size=int(data[\"max_batch_size\"]),\n            max_cost=_optional_float(data.get(\"max_cost\")),\n            source=source,\n        )","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/managers/dynamic_batch_admission.py#L65-L101","documentation":"A batching configuration rule is expected to be a JSON object (mapping of option names to values), but the parsed entry is some other JSON type (list, string, number, null, boolean). BatchingRule.from_dict validates shape before reading fields like max_batch_size.","triggerScenarios":"load_batching_config parses a batching config file where a rule entry is not a dict — e.g. a list of values, a bare string, or null — and passes it to BatchingRule.from_dict(data, source=...).","commonSituations":"Hand-edited YAML/JSON batching config where a rule is written as a list or scalar; schema change from an older array-based format; missing entry rendered as null.","solutions":["Fix the config so each rule is an object with keys like max_batch_size, e.g. {\"max_batch_size\": 8}","Check the error's source field to find which file/section is malformed","Validate the config with a JSON schema or by loading it in a dry-run before starting the server"],"exampleFix":"# before\nbatching_rules:\n  - 8\n# after\nbatching_rules:\n  - max_batch_size: 8","handlingStrategy":"type-guard","validationCode":"def rules_well_formed(rules) -> bool:\n    return all(isinstance(r, dict) for r in rules)","typeGuard":"from typing import Any\n\ndef is_batching_rule_dict(data: Any) -> bool:\n    \"\"\"Narrow a parsed JSON node to a BatchingRule-shaped dict.\"\"\"\n    return isinstance(data, dict) and \"max_batch_size\" in data","tryCatchPattern":"try:\n    BatchingRule.from_dict(rule, source=path)\nexcept ValueError as e:\n    logger.error(\"invalid batching rule in %s: %s\", path, e)\n    raise SystemExit(2)","preventionTips":["Validate batching config files with a JSON schema before deploying","Keep each rule an object with explicit keys (max_batch_size, max_cost); avoid bare scalars or lists","Add a config dry-run/lint step to CI for hand-edited configs"],"tags":["batching","config","schema-validation","json"],"backgroundTag":"schema-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}