{"record":{"id":"f6e33c8fc197e475","repo":"vllm-project/vllm","slug":"unsupported-type-for-size-type-value","errorCode":null,"errorMessage":"Unsupported type for size: {type(value)}","messagePattern":"Unsupported type for size: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"vllm/distributed/kv_transfer/kv_connector/v1/mooncake/store/worker.py","lineNumber":199,"sourceCode":"    if value is None:\n        return DEFAULT_TENANT_ID\n    if not isinstance(value, str):\n        raise TypeError(\n            f\"tenant_id must be a string or null, got {type(value).__name__}: {value!r}\"\n        )\n    tenant_id = value.strip()\n    return tenant_id if tenant_id else DEFAULT_TENANT_ID\n\n\ndef _parse_size(value: Any) -> int:\n    \"\"\"Parse storage size strings with units: GB, MB, KB, B.\"\"\"\n    if isinstance(value, int):\n        return value\n    if not isinstance(value, str):\n        try:\n            return int(value)\n        except (TypeError, ValueError) as e:\n            raise TypeError(f\"Unsupported type for size: {type(value)}\") from e\n\n    cleaned = value.strip().lower()\n    if not cleaned:\n        raise ValueError(\"Size cannot be empty.\")\n\n    unit_multipliers = {\n        \"gb\": 1024**3,\n        \"mb\": 1024**2,\n        \"kb\": 1024,\n        \"b\": 1,\n    }\n    match = re.match(r\"^\\s*([\\d.]+)\\s*(gb|mb|kb|b)?\\s*$\", cleaned)\n    if not match:\n        raise ValueError(f\"Invalid format: '{value}'\")\n\n    number_str = match.group(1)\n    unit = match.group(2) or \"b\"\n    multiplier = unit_multipliers[unit]","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/vllm/distributed/kv_transfer/kv_connector/v1/mooncake/store/worker.py#L181-L217","documentation":"_parse_size converts global_segment_size / local_buffer_size values to byte counts. Non-int, non-str inputs (float, bool, list, None) are attempted via int(value); if that fails it raises TypeError with the value's type. Note bools and floats that do convert silently succeed, so this error means a genuinely unconvertible type.","triggerScenarios":"\"global_segment_size\": [\"8GB\"] or 1.5e9's string-less cousin such as an embedded object in the config JSON; a float like 1.5 (int() truncates it — no error) vs a list/dict (error).","commonSituations":"Templating systems injecting structured values where a scalar was expected; hand-edited JSON putting arrays around sizes.","solutions":["Use a plain int (bytes) or a unit string like \"8GB\" for size fields in the mooncake config","Remove any list/object wrapper around the value"],"exampleFix":"// before\n{ \"global_segment_size\": [\"8GB\"] }\n\n// after\n{ \"global_segment_size\": \"8GB\" }","handlingStrategy":"type-guard","validationCode":"for k in (\"global_segment_size\", \"local_buffer_size\"):\n    v = raw.get(k)\n    if not isinstance(v, (int, str)):\n        raise TypeError(f\"{k} must be int or size string\")","typeGuard":"def is_valid_size_input(v) -> bool:\n    return isinstance(v, (int, str))","tryCatchPattern":null,"preventionTips":["Keep size fields scalar in generated configs","Use unit strings uniformly (\"8GB\") to avoid ambiguity"],"tags":["mooncake","config","type-error","parsing"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}