{"record":{"id":"be1278bc5c3fcb8e","repo":"sgl-project/sglang","slug":"cache-salt-should-be-a-list-or-a-string","errorCode":null,"errorMessage":"cache_salt should be a list or a string.","messagePattern":"cache_salt should be a list or a string\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/managers/io_struct.py","lineNumber":816,"sourceCode":"\n    def _normalize_cache_salt(self, num):\n        \"\"\"Normalize cache_salt for batch processing.\"\"\"\n        if self.cache_salt is None:\n            return\n        if isinstance(self.cache_salt, str):\n            value = self.cache_salt or None\n            self.cache_salt = [value] * num\n        elif isinstance(self.cache_salt, list):\n            if len(self.cache_salt) != self.batch_size:\n                raise ValueError(\n                    \"The length of cache_salt should be equal to the batch size.\"\n                )\n            if any(not isinstance(value, str) for value in self.cache_salt):\n                raise ValueError(\"Every cache_salt should be a string.\")\n            self.cache_salt = [value or None for value in self.cache_salt]\n            self.cache_salt = self.cache_salt * self.parallel_sample_num\n        else:\n            raise ValueError(\"cache_salt should be a list or a string.\")\n\n    def _normalize_bootstrap_params(self, num):\n        \"\"\"Normalize bootstrap parameters for batch processing.\"\"\"\n        # Normalize bootstrap_host\n        if self.bootstrap_host is None:\n            self.bootstrap_host = [None] * num\n        elif not isinstance(self.bootstrap_host, list):\n            self.bootstrap_host = [self.bootstrap_host] * num\n        elif isinstance(self.bootstrap_host, list):\n            self.bootstrap_host = self.bootstrap_host * self.parallel_sample_num\n\n        # Normalize bootstrap_port\n        if self.bootstrap_port is None:\n            self.bootstrap_port = [None] * num\n        elif not isinstance(self.bootstrap_port, list):\n            self.bootstrap_port = [self.bootstrap_port] * num\n        elif isinstance(self.bootstrap_port, list):\n            self.bootstrap_port = self.bootstrap_port * self.parallel_sample_num","sourceCodeStart":798,"sourceCodeEnd":834,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/managers/io_struct.py#L798-L834","documentation":"Raised when cache_salt is neither None, str, nor list. The normalizer accepts None (skip), a str (broadcast), or a list[str] (per-request); anything else is rejected before dispatch.","triggerScenarios":"cache_salt=42, cache_salt=('s1','s2') (tuple), or a dict.","commonSituations":"Passing tuple from an API layer, or numeric salt ids.","solutions":["Use str, list[str], or None","Convert tuples: list(tuple)"],"exampleFix":"// before\ncache_salt=('s1','s2')\n// after\ncache_salt=['s1','s2']","handlingStrategy":"type-guard","validationCode":"cache_salt = list(cache_salt) if isinstance(cache_salt, tuple) else cache_salt","typeGuard":"def valid_salt(s): return s is None or isinstance(s, (str, list))","tryCatchPattern":null,"preventionTips":["Document accepted types: None | str | list[str]"],"tags":["sglang","cache-salt","type-error"],"backgroundTag":"request-input-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}