sgl-project/sglang · error · ValueError
Invalid combination of query/items types for score_request.
Error message
Invalid combination of query/items types for score_request.
What it means
score_request dispatches on the shapes of query and items: it supports str/str, str/list, list/str, and list/list (plus embed-override variants). Any other type combination (e.g. None, int, nested lists of unequal depth, numpy arrays, dicts) falls through to this catch-all ValueError.
Source
Thrown at python/sglang/srt/managers/tokenizer_manager_score_mixin.py:579
item_embed_overrides,
)
)
elif has_embeds:
# Text inputs with embed overrides — need to tokenize first to resolve positions
query_ids, items_ids = self._batch_tokenize_query_and_items(query, items)
_, input_ids, positional_embed_overrides, delimiter_indices = (
self._build_token_id_inputs(
query_ids,
items_ids,
item_first,
use_multi_item_scoring,
embed_override_token_id,
query_embed_overrides,
item_embed_overrides,
)
)
else:
raise ValueError(
"Invalid combination of query/items types for score_request."
)
if return_pooled_hidden_states:
if is_generation:
raise ValueError(
"return_pooled_hidden_states is not supported for CausalLM models. "
"It requires a model with a task-specific head "
"(e.g. SequenceClassification or RewardModel)."
)
model_config = self.model_config
if model_config is not None:
archs = getattr(model_config.hf_config, "architectures", []) or []
if is_cross_encoding_pooler_model(archs):
raise ValueError(
f"return_pooled_hidden_states is not supported for "
f"{archs[0]}. This model uses CrossEncodingPooler which "
f"does not expose pre-head hidden states."View on GitHub (pinned to 0132848349)
Solutions
- Normalize query/items to plain Python str or list[str] (call .tolist() on numpy arrays)
- Ensure outer list lengths match when both are lists
- Check for None/empty inputs before calling score and skip or default them
Example fix
# before await engine.async_score(np.array(texts), [item]) # after await engine.async_score(list(np.array(texts)), [item])
Defensive patterns
Strategy: type-guard
Validate before calling
assert isinstance(query, (str, list)) and isinstance(items, (str, list)) assert all(isinstance(x, str) for x in ([query] if isinstance(query, str) else query))
Type guard
def valid_score_args(query, items) -> bool:
ok = lambda v: isinstance(v, str) or (isinstance(v, list) and v and all(isinstance(x, str) for x in v))
if isinstance(query, list) and isinstance(items, list) and isinstance(items[0], list):
return ok(query) and len(query) == len(items) and all(ok(i) for i in items)
return ok(query) and ok(items) Prevention
- Convert numpy/torch arrays to plain lists before calling score
- Guard against None inputs from dynamic payloads
When it happens
Trigger: Calling score with query=None, items being a generator or numpy array, mismatched nesting (list vs list-of-lists with unequal lengths in cross-scoring mode), or passing embeddings in a shape the dispatcher does not recognize.
Common situations: Dynamically built request payloads where query or items can be None; converting arrays to numpy; passing a list of queries with a list of list-of-items of different length.
Understand the failure class
Background: Invalid argument type errors: "must be of type string", "expected X, got Y", and ERR_INVALID_ARG_TYPE explained — this error's family across 15 libraries.
Related errors
- actions must be a list[list[str]]
- Inkling reasoning_effort must not be a boolean
- cuda-graph mode cu_seqlens should be a list
- flashinfer_cudnn expects packed indptrs as a torch.Tensor
- Invalid prompts type for score_prompts.
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/69856a8380bc075c.
Report an issue: GitHub.