{"record":{"id":"969e4da3e15d50e1","repo":"sgl-project/sglang","slug":"unknown-cacheaware-policy-policy","errorCode":null,"errorMessage":"Unknown CacheAware Policy: {policy=}","messagePattern":"Unknown CacheAware Policy: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/managers/schedule_policy.py","lineNumber":272,"sourceCode":"        if self.policy == CacheAgnosticPolicy.FCFS:\n            if self.enable_priority_scheduling:\n                SchedulePolicy._sort_by_priority_and_fcfs(\n                    waiting_queue, self.priority_sign\n                )\n            return\n\n        if isinstance(policy, CacheAwarePolicy):\n            temporary_deprioritized = self._compute_prefix_matches(\n                waiting_queue, policy\n            )\n            if policy == CacheAwarePolicy.LPM:\n                SchedulePolicy._sort_by_longest_prefix(\n                    waiting_queue, temporary_deprioritized\n                )\n            elif policy == CacheAwarePolicy.DFS_WEIGHT:\n                SchedulePolicy._sort_by_dfs_weight(waiting_queue, self.tree_cache)\n            else:\n                raise ValueError(f\"Unknown CacheAware Policy: {policy=}\")\n        else:\n            if policy == CacheAgnosticPolicy.FCFS:\n                pass\n            elif policy == CacheAgnosticPolicy.LOF:\n                SchedulePolicy._sort_by_longest_output(\n                    waiting_queue,\n                    self.enable_priority_scheduling,\n                    self.priority_sign,\n                )\n            elif policy == CacheAgnosticPolicy.RANDOM:\n                SchedulePolicy._sort_randomly(waiting_queue)\n            elif policy == CacheAgnosticPolicy.ROUTING_KEY:\n                if running_batch is not None:\n                    SchedulePolicy._sort_by_routing_key(waiting_queue, running_batch)\n            else:\n                raise ValueError(f\"Unknown CacheAgnostic Policy: {policy=}\")\n\n    def _determine_active_policy(self, waiting_queue: List[Req]) -> Policy:","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/managers/schedule_policy.py#L254-L290","documentation":"Thrown by SchedulePolicy.calc_priority when the configured policy was recognized as a CacheAwarePolicy variant but did not match any known CacheAwarePolicy enum member (LPM, DFS_WEIGHT). It signals an unrecognized cache-aware scheduling policy string reached the sort dispatch.","triggerScenarios":"Passing a policy value to SchedulePolicy that parses as a CacheAwarePolicy branch but is not LPM or DFS_WEIGHT, e.g. via schedule_policy server arg or a custom policy string; reached through get_new_batch_prefill_raw / get_new_prebuilt_batch.","commonSituations":"Typos in --schedule-policy, using a policy name from an older/newer sglang version, or programmatic construction of SchedulePolicy with an invalid enum value.","solutions":["Check the --schedule-policy value against CacheAwarePolicy enum members (lpm, dfs-weight)","Upgrade or align the client code with the sglang version whose enum set matches","If adding a new policy, implement its sort branch in calc_priority"],"exampleFix":"# before\npython -m sglang.launch_server --schedule-policy cache_aware_typo\n# after\npython -m sglang.launch_server --schedule-policy lpm","handlingStrategy":"validation","validationCode":"from sglang.srt.managers.schedule_policy import CacheAwarePolicy\nvalid = {p.value for p in CacheAwarePolicy}\nassert policy in valid, f'unknown cache-aware policy {policy}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate policy strings against CacheAwarePolicy before constructing SchedulePolicy","Pin your sglang version so enum members don't shift under you"],"tags":["scheduling","config","enum-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}