sgl-project/sglang · error · ValueError
Every cache_salt should be a string.
Error message
Every cache_salt should be a string.
What it means
Raised when cache_salt is a list containing at least one non-string element. Each per-request salt must be a str (empty string normalizes to None, meaning no salting).
Source
Thrown at python/sglang/srt/managers/io_struct.py:812
self.extra_key = [value or None for value in self.extra_key]
self.extra_key = self.extra_key * self.parallel_sample_num
else:
raise ValueError("extra_key should be a list or a string.")
def _normalize_cache_salt(self, num):
"""Normalize cache_salt for batch processing."""
if self.cache_salt is None:
return
if isinstance(self.cache_salt, str):
value = self.cache_salt or None
self.cache_salt = [value] * num
elif isinstance(self.cache_salt, list):
if len(self.cache_salt) != self.batch_size:
raise ValueError(
"The length of cache_salt should be equal to the batch size."
)
if any(not isinstance(value, str) for value in self.cache_salt):
raise ValueError("Every cache_salt should be a string.")
self.cache_salt = [value or None for value in self.cache_salt]
self.cache_salt = self.cache_salt * self.parallel_sample_num
else:
raise ValueError("cache_salt should be a list or a string.")
def _normalize_bootstrap_params(self, num):
"""Normalize bootstrap parameters for batch processing."""
# Normalize bootstrap_host
if self.bootstrap_host is None:
self.bootstrap_host = [None] * num
elif not isinstance(self.bootstrap_host, list):
self.bootstrap_host = [self.bootstrap_host] * num
elif isinstance(self.bootstrap_host, list):
self.bootstrap_host = self.bootstrap_host * self.parallel_sample_num
# Normalize bootstrap_port
if self.bootstrap_port is None:
self.bootstrap_port = [None] * numView on GitHub (pinned to 0132848349)
Solutions
- Convert elements to str: [str(s) for s in salts]
- Use '' for requests needing no salt
- Use a single str for uniform salting
Example fix
// before cache_salt=[b'hash1', b'hash2'] // after cache_salt=['hash1', 'hash2']
Defensive patterns
Strategy: validation
Validate before calling
assert all(isinstance(s, str) for s in cache_salt), 'salts must be str'
Prevention
- str() salts at construction; '' means no salt
When it happens
Trigger: cache_salt=[None, 's'] or [1, 2] with batch_size=2.
Common situations: Using bytes from hashes, ints, or None placeholders in the salt list.
Related errors
- extra_key should be a list or a string.
- The length of cache_salt should be equal to the batch size.
- cache_salt should be a list or a string.
- Unsupported image type: {type(image)}
- MiniMax H3 model variant must be a non-empty string
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/5e89d0217e640c72.
Report an issue: GitHub.