{"record":{"id":"db4b9f77c07149f1","repo":"sgl-project/sglang","slug":"prefetch-timeout-base-must-be-number-got-type-pr","errorCode":null,"errorMessage":"prefetch_timeout_base must be number, got {type(prefetch_timeout_base).__name__}","messagePattern":"prefetch_timeout_base must be number, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/mem_cache/hiradix_cache.py","lineNumber":769,"sourceCode":"        prefetch_timeout_base = extra_config.pop(\n            \"prefetch_timeout_base\", defaults.base\n        )  # seconds\n        prefetch_timeout_per_ki_token = extra_config.pop(\n            \"prefetch_timeout_per_ki_token\", defaults.per_ki_token\n        )  # seconds per 1024 tokens\n        prefetch_timeout_max = extra_config.pop(\n            \"prefetch_timeout_max\", defaults.max\n        )  # seconds, upper bound for the linear timeout\n        hicache_storage_pass_prefix_keys = extra_config.pop(\n            \"hicache_storage_pass_prefix_keys\", False\n        )\n\n        if not isinstance(prefetch_threshold, int):\n            raise ValueError(\n                f\"prefetch_threshold must be int, got {type(prefetch_threshold).__name__}\"\n            )\n        if not isinstance(prefetch_timeout_base, (int, float)):\n            raise ValueError(\n                f\"prefetch_timeout_base must be number, got {type(prefetch_timeout_base).__name__}\"\n            )\n        if not isinstance(prefetch_timeout_per_ki_token, (int, float)):\n            raise ValueError(\n                f\"prefetch_timeout_per_ki_token must be number, got {type(prefetch_timeout_per_ki_token).__name__}\"\n            )\n        if not isinstance(prefetch_timeout_max, (int, float)):\n            raise ValueError(\n                f\"prefetch_timeout_max must be number, got {type(prefetch_timeout_max).__name__}\"\n            )\n        if not isinstance(hicache_storage_pass_prefix_keys, bool):\n            raise ValueError(\n                \"hicache_storage_pass_prefix_keys must be bool, got \"\n                f\"{type(hicache_storage_pass_prefix_keys).__name__}\"\n            )\n\n        prefetch_timeout_config = PrefetchTimeoutConfig(\n            base=float(prefetch_timeout_base),","sourceCodeStart":751,"sourceCodeEnd":787,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/mem_cache/hiradix_cache.py#L751-L787","documentation":"Validates that prefetch_timeout_base in the parsed storage backend extra config is a number (int or float). Values that YAML/TOML parse as strings — quoted \"10\", or non-numeric text — fail isinstance((int, float)) and raise this ValueError with the actual type name.","triggerScenarios":"Extra config (YAML/TOML file or JSON string) containing prefetch_timeout_base: \"10\" (string), true (bool), null, or a non-numeric value.","commonSituations":"Quoting numbers in YAML; template engines rendering values as strings; env-var interpolation producing strings; omitting the key where a default is itself a string.","solutions":["Unquote the value and make it numeric: prefetch_timeout_base: 10 or 10.5","Check for templating/env interpolation that stringifies the value and cast before writing the config","Confirm units — this is seconds, the linear timeout base — while fixing"],"exampleFix":"# before\nprefetch_timeout_base: \"10\"\n\n# after\nprefetch_timeout_base: 10","handlingStrategy":"type-guard","validationCode":"v = cfg.get(\"prefetch_timeout_base\", 10)\nassert isinstance(v, (int, float)) and not isinstance(v, bool), \"prefetch_timeout_base must be numeric\"","typeGuard":"def is_number_not_bool(v) -> bool:\n    return isinstance(v, (int, float)) and not isinstance(v, bool)","tryCatchPattern":null,"preventionTips":["Never quote numeric config values in YAML","If generating config from templates, cast numbers explicitly with int()/float()"],"tags":["hicache","config-validation","prefetch","type-error"],"backgroundTag":"config-type-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}