{"record":{"id":"fe83f6b97d5aba04","repo":"sgl-project/sglang","slug":"prefetch-timeout-max-must-be-number-got-type-pre","errorCode":null,"errorMessage":"prefetch_timeout_max must be number, got {type(prefetch_timeout_max).__name__}","messagePattern":"prefetch_timeout_max must be number, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/mem_cache/hiradix_cache.py","lineNumber":777,"sourceCode":"        )  # 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),\n            per_ki_token=float(prefetch_timeout_per_ki_token),\n            max=float(prefetch_timeout_max),\n        )\n\n        return (\n            extra_config,\n            prefetch_threshold,\n            prefetch_timeout_config,","sourceCodeStart":759,"sourceCodeEnd":795,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/mem_cache/hiradix_cache.py#L759-L795","documentation":"Validates that prefetch_timeout_max (upper bound in seconds for the linear prefetch timeout) in the parsed storage backend extra config is an int or float. Non-numeric parsed values (quoted strings, bools, nulls) raise this ValueError including the actual type name.","triggerScenarios":"Extra config with prefetch_timeout_max: \"30\", true, null, or a non-number (e.g. a list or map).","commonSituations":"Stringified numbers from templates/env substitution in generated configs; quoting values in YAML 'just to be safe'; missing key defaulting to a string in a custom config pipeline.","solutions":["Set the value as a bare number: prefetch_timeout_max: 30","Audit any script that generates the config and coerce numerics before serialization","After fixing, ensure prefetch_timeout_max >= prefetch_timeout_base for a sane timeout policy"],"exampleFix":"# before\nprefetch_timeout_max: \"30\"\n\n# after\nprefetch_timeout_max: 30","handlingStrategy":"type-guard","validationCode":"v = cfg.get(\"prefetch_timeout_max\", 30)\nassert isinstance(v, (int, float)) and not isinstance(v, bool), \"prefetch_timeout_max 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":["Keep timeout fields bare numbers in config files","Ensure prefetch_timeout_max >= prefetch_timeout_base when tuning"],"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"}