{"record":{"id":"93bc5997b30730d6","repo":"sgl-project/sglang","slug":"elements-must-be-int-or-list-got-type-v-0-na","errorCode":null,"errorMessage":"elements must be int or list; got {type(v[0]).__name__}","messagePattern":"elements must be int or list; got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/utils/field_validators.py","lineNumber":81,"sourceCode":"        # Accept None\n        return v\n    if not isinstance(v, list):\n        raise ValueError(f\"must be list or null; got {type(v).__name__}\")\n    if not v:\n        # Accept empty list\n        return v\n    if isinstance(v[0], int):\n        # Accept list[int]\n        return validate_list_i64_1d(v)\n    if isinstance(v[0], list):\n        # Accept list[list[int]]\n        for i, row in enumerate(v):\n            try:\n                validate_list_i64_1d(row)\n            except ValueError as e:\n                raise ValueError(f\"row {i}: {e}\") from None\n        return v\n    raise ValueError(f\"elements must be int or list; got {type(v[0]).__name__}\")\n","sourceCodeStart":63,"sourceCodeEnd":82,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/utils/field_validators.py#L63-L82","documentation":"The outer value is a non-empty list but its first element is neither an int nor a list, so the validator cannot decide between 1D and 2D shapes and rejects the input.","triggerScenarios":"Passing ['1','2'], [None], [[1],'2'] style lists, or a list of dicts/tuples where list[int] | list[list[int]] is expected.","commonSituations":"Parsing CLI input as strings and passing through unparsed, or JSON configs with mixed types.","solutions":["Convert string elements to int before passing (e.g. [int(x) for x in vals])","Remove None/dict/tuple elements","If you meant nested rows, wrap each element in a list"],"exampleFix":"# before\narg = ['1', '2', '3']\n# after\narg = [1, 2, 3]","handlingStrategy":"validation","validationCode":"first = v[0] if v else None\nassert first is None or type(first) in (int, list), f'bad first element {first!r}'","typeGuard":"def has_homogeneous_first(v) -> TypeGuard[list]:\n    return isinstance(v, list) and (not v or type(v[0]) in (int, list))","tryCatchPattern":null,"preventionTips":["Convert CLI string args with [int(x) for x in s.split(',')]","Never mix strings and ints in config lists"],"tags":["validation","type-error","config"],"backgroundTag":"list-element-type-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}