sgl-project/sglang · error · ValueError
hicache_storage_pass_prefix_keys must be bool, got {type(hic
Error message
hicache_storage_pass_prefix_keys must be bool, got {type(hicache_storage_pass_prefix_keys).__name__} What it means
Validates that hicache_storage_pass_prefix_keys in the parsed extra config is strictly a bool. Python bools are required, so 0/1, "true"/"false" strings, or yes/no (which YAML may or may not coerce depending on quoting) fail the isinstance(x, bool) check.
Source
Thrown at python/sglang/srt/mem_cache/hiradix_cache.py:781
if not isinstance(prefetch_threshold, int):
raise ValueError(
f"prefetch_threshold must be int, got {type(prefetch_threshold).__name__}"
)
if not isinstance(prefetch_timeout_base, (int, float)):
raise ValueError(
f"prefetch_timeout_base must be number, got {type(prefetch_timeout_base).__name__}"
)
if not isinstance(prefetch_timeout_per_ki_token, (int, float)):
raise ValueError(
f"prefetch_timeout_per_ki_token must be number, got {type(prefetch_timeout_per_ki_token).__name__}"
)
if not isinstance(prefetch_timeout_max, (int, float)):
raise ValueError(
f"prefetch_timeout_max must be number, got {type(prefetch_timeout_max).__name__}"
)
if not isinstance(hicache_storage_pass_prefix_keys, bool):
raise ValueError(
"hicache_storage_pass_prefix_keys must be bool, got "
f"{type(hicache_storage_pass_prefix_keys).__name__}"
)
prefetch_timeout_config = PrefetchTimeoutConfig(
base=float(prefetch_timeout_base),
per_ki_token=float(prefetch_timeout_per_ki_token),
max=float(prefetch_timeout_max),
)
return (
extra_config,
prefetch_threshold,
prefetch_timeout_config,
hicache_storage_pass_prefix_keys,
)
def reset(self):View on GitHub (pinned to 0132848349)
Solutions
- Use an unquoted boolean literal: hicache_storage_pass_prefix_keys: true (YAML) or true (JSON/TOML lowercase)
- Never quote the value or substitute 1/0
- Regenerate tool-produced configs so booleans stay native JSON/TOML booleans
Example fix
# before hicache_storage_pass_prefix_keys: "true" # after hicache_storage_pass_prefix_keys: true
Defensive patterns
Strategy: type-guard
Validate before calling
v = cfg.get("hicache_storage_pass_prefix_keys", False)
assert isinstance(v, bool), "hicache_storage_pass_prefix_keys must be a real bool (true/false, unquoted)" Type guard
def is_strict_bool(v) -> bool:
return isinstance(v, bool) Prevention
- Use lowercase true/false in YAML/TOML/JSON, never quoted and never 0/1
- Prefer native booleans over string flags in generated configs
When it happens
Trigger: Extra config with hicache_storage_pass_prefix_keys: "true" (quoted string), 1/0 (int), or 'yes' handled as string in TOML/JSON where only true/false booleans exist.
Common situations: Quoting booleans in YAML; using 0/1 flags from CLI-style thinking; JSON configs generated by tools that emit strings for flags; TOML requires lowercase true/false — True/TRUE in some generators become strings.
Related errors
- prefetch_threshold must be int, got {type(prefetch_threshold
- prefetch_timeout_base must be number, got {type(prefetch_tim
- prefetch_timeout_per_ki_token must be number, got {type(pref
- prefetch_timeout_max must be number, got {type(prefetch_time
- Invalid layerwise offload component name: {raw_component}.
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/3135db1ddef556a2.
Report an issue: GitHub.