{"record":{"id":"a59b98182920e2da","repo":"sgl-project/sglang","slug":"prefetch-timeout-per-ki-token-must-be-number-got","errorCode":null,"errorMessage":"prefetch_timeout_per_ki_token must be number, got {type(prefetch_timeout_per_ki_token).__name__}","messagePattern":"prefetch_timeout_per_ki_token must be number, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/mem_cache/hiradix_cache.py","lineNumber":773,"sourceCode":"            \"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),\n            per_ki_token=float(prefetch_timeout_per_ki_token),\n            max=float(prefetch_timeout_max),\n        )\n","sourceCodeStart":755,"sourceCodeEnd":791,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/mem_cache/hiradix_cache.py#L755-L791","documentation":"Validates that prefetch_timeout_per_ki_token (the per-1000-token slope of the linear prefetch timeout, in seconds) in the parsed extra config is an int or float. String, bool, null, or list values fail the isinstance check and raise with the offending type name.","triggerScenarios":"Extra config containing prefetch_timeout_per_ki_token: \"0.5\", null, true, or a list — anything YAML/TOML/JSON parses to a non-number.","commonSituations":"Quoted numeric strings in YAML configs; copy-paste from docs that render numbers as strings; misnested YAML putting the key under the wrong mapping so it resolves to null.","solutions":["Write the value as a bare number: prefetch_timeout_per_ki_token: 0.5","Fix YAML indentation so the key sits at the top level of the extra-config mapping (not nested elsewhere, yielding null)","Validate the config with a quick yaml.safe_load + isinstance check before launching"],"exampleFix":"# before\nprefetch_timeout_per_ki_token: \"0.5\"\n\n# after\nprefetch_timeout_per_ki_token: 0.5","handlingStrategy":"type-guard","validationCode":"v = cfg.get(\"prefetch_timeout_per_ki_token\", 0.1)\nassert isinstance(v, (int, float)) and not isinstance(v, bool), \"prefetch_timeout_per_ki_token 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":["Check YAML indentation so keys resolve to values, not null","Smoke-test the extra config with yaml.safe_load + isinstance checks in CI"],"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"}