{"record":{"id":"69856a8380bc075c","repo":"sgl-project/sglang","slug":"invalid-combination-of-query-items-types-for-score","errorCode":null,"errorMessage":"Invalid combination of query/items types for score_request.","messagePattern":"Invalid combination of query/items types for score_request\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/managers/tokenizer_manager_score_mixin.py","lineNumber":579,"sourceCode":"                    item_embed_overrides,\n                )\n            )\n        elif has_embeds:\n            # Text inputs with embed overrides — need to tokenize first to resolve positions\n            query_ids, items_ids = self._batch_tokenize_query_and_items(query, items)\n            _, input_ids, positional_embed_overrides, delimiter_indices = (\n                self._build_token_id_inputs(\n                    query_ids,\n                    items_ids,\n                    item_first,\n                    use_multi_item_scoring,\n                    embed_override_token_id,\n                    query_embed_overrides,\n                    item_embed_overrides,\n                )\n            )\n        else:\n            raise ValueError(\n                \"Invalid combination of query/items types for score_request.\"\n            )\n\n        if return_pooled_hidden_states:\n            if is_generation:\n                raise ValueError(\n                    \"return_pooled_hidden_states is not supported for CausalLM models. \"\n                    \"It requires a model with a task-specific head \"\n                    \"(e.g. SequenceClassification or RewardModel).\"\n                )\n            model_config = self.model_config\n            if model_config is not None:\n                archs = getattr(model_config.hf_config, \"architectures\", []) or []\n                if is_cross_encoding_pooler_model(archs):\n                    raise ValueError(\n                        f\"return_pooled_hidden_states is not supported for \"\n                        f\"{archs[0]}. This model uses CrossEncodingPooler which \"\n                        f\"does not expose pre-head hidden states.\"","sourceCodeStart":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/managers/tokenizer_manager_score_mixin.py#L561-L597","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nawait engine.async_score(np.array(texts), [item])\n# after\nawait engine.async_score(list(np.array(texts)), [item])","handlingStrategy":"type-guard","validationCode":"assert isinstance(query, (str, list)) and isinstance(items, (str, list))\nassert all(isinstance(x, str) for x in ([query] if isinstance(query, str) else query))","typeGuard":"def valid_score_args(query, items) -> bool:\n    ok = lambda v: isinstance(v, str) or (isinstance(v, list) and v and all(isinstance(x, str) for x in v))\n    if isinstance(query, list) and isinstance(items, list) and isinstance(items[0], list):\n        return ok(query) and len(query) == len(items) and all(ok(i) for i in items)\n    return ok(query) and ok(items)","tryCatchPattern":null,"preventionTips":["Convert numpy/torch arrays to plain lists before calling score","Guard against None inputs from dynamic payloads"],"tags":["sglang","scoring","type-validation"],"backgroundTag":"invalid-argument-type","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}