{"record":{"id":"bad67b5f1061dba0","repo":"sgl-project/sglang","slug":"name-must-be-true-false-str-list-str-got","errorCode":null,"errorMessage":"{name} must be True / False / str / list[str], got {value!r}","messagePattern":"(.+?) must be True / False / str / list\\[str\\], got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/utils/rank_consensus_checker.py","lineNumber":166,"sourceCode":"        return decorator\n\n\ndef _normalize_selector(\n    value: None | bool | str | list[str], name: str\n) -> None | bool | list[str]:\n    \"\"\"Normalize a selector argument to one of:\n    ``None`` (skip), ``True`` (compare everything), or ``list[str]`` (the\n    expressions to evaluate). ``False`` is treated as ``None``.\n    \"\"\"\n    if value is None or value is False:\n        return None\n    if value is True:\n        return True\n    if isinstance(value, str):\n        return [value]\n    if isinstance(value, list) and all(isinstance(s, str) for s in value):\n        return list(value)\n    raise TypeError(f\"{name} must be True / False / str / list[str], got {value!r}\")\n\n\ndef _is_method_with_receiver(func: Any) -> bool:\n    \"\"\"Return True iff ``func`` is a method whose first parameter is a\n    receiver (instance for instance-methods, class for class-methods) that\n    should be dropped from the ``same_params=True`` payload.\n\n    Distinguishes:\n      * ``staticmethod`` object  -> False (no receiver)\n      * ``classmethod``  object  -> True  (receiver is the class)\n      * plain ``def`` defined inside a class body (``__qualname__`` has a\n        dot before the final segment and is not a ``<locals>`` closure) ->\n        True  (instance method)\n      * anything else (module-level function, nested function, lambda) ->\n        False\n    \"\"\"\n    if isinstance(func, staticmethod):\n        return False","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/utils/rank_consensus_checker.py#L148-L184","documentation":"_normalize_selector validates the same_params/same_results options of rank_consensus: each must be True, False, a single parameter-name string, or a list of strings. Anything else (None, int, nested lists, mixed-type lists) raises TypeError naming the offending option.","triggerScenarios":"@rank_consensus(same_params=None), same_params=1, or same_params=['a', 2] where a list contains non-strings.","commonSituations":"Config-driven decorator options parsed from YAML/JSON where a value becomes None or a non-string type; typos intending True.","solutions":["Use booleans or parameter-name strings/lists of strings only","Coerce config values: None -> False, ensure list elements are strings","Validate options before applying the decorator when they come from dynamic config"],"exampleFix":"# before\n@rank_consensus(same_params=None)\ndef fn(): ...\n# after\n@rank_consensus(same_params=False)\ndef fn(): ...","handlingStrategy":"validation","validationCode":"def valid_selector(v) -> bool:\n    return v is True or v is False or isinstance(v, str) or (isinstance(v, list) and all(isinstance(s, str) for s in v))","typeGuard":"def is_selector(v) -> bool:\n    return v is True or v is False or isinstance(v, str) or (isinstance(v, list) and all(isinstance(x, str) for x in v))","tryCatchPattern":"try:\n    rank_consensus(same_params=opt)\nexcept TypeError as e:\n    if 'must be True / False / str / list[str]' in str(e):\n        opt = bool(opt); rank_consensus(same_params=opt)","preventionTips":["Coerce config-sourced decorator options (None->False)","Type-check lists of parameter names","Unit-test decorator configuration parsing"],"tags":["decorator","distributed","type-validation","rank-consensus","sglang"],"backgroundTag":"invalid-decorator-arguments","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}