{"record":{"id":"a5a966fb4ab6dcfd","repo":"sgl-project/sglang","slug":"text-and-input-ids-cannot-be-provided-at-the-same","errorCode":null,"errorMessage":"text and input_ids cannot be provided at the same time","messagePattern":"text and input_ids cannot be provided at the same time","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/managers/io_struct.py","lineNumber":1186,"sourceCode":"    def _validate_rid_uniqueness(self):\n        \"\"\"Validate that request IDs within a batch are unique.\"\"\"\n        if isinstance(self.rid, list) and len(set(self.rid)) != len(self.rid):\n            counts = Counter(self.rid)\n            duplicates = [rid for rid, count in counts.items() if count > 1]\n            raise ValueError(\n                f\"Duplicate request IDs detected within the request: {duplicates}\"\n            )\n\n    def normalize_batch_and_arguments(self):\n        # at least one of text, input_ids, or image should be provided\n        if self.text is None and self.input_ids is None and self.image_data is None:\n            raise ValueError(\n                \"At least one of text, input_ids, or image should be provided\"\n            )\n\n        # text and input_ids cannot be provided at the same time\n        if self.text is not None and self.input_ids is not None:\n            raise ValueError(\"text and input_ids cannot be provided at the same time\")\n\n        # Derive the batch size\n        self.batch_size = 0\n        self.is_single = True\n\n        # check the batch size of text\n        if self.text is not None:\n            if isinstance(self.text, list):\n                self.batch_size += len(self.text)\n                self.is_single = False\n            else:\n                self.batch_size += 1\n\n        # check the batch size of input_ids\n        if self.input_ids is not None:\n            if isinstance(self.input_ids[0], list):\n                self.batch_size += len(self.input_ids)\n                self.is_single = False","sourceCodeStart":1168,"sourceCodeEnd":1204,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/managers/io_struct.py#L1168-L1204","documentation":"A request may be seeded by exactly one of raw text or pre-tokenized input_ids, not both — tokenizing text that also carries input_ids is ambiguous. Raised at the start of normalize_batch_and_arguments.","triggerScenarios":"GenerateReqInput(text='hi', input_ids=[1,2,3]); chat clients that attach cached token ids while still forwarding the raw prompt string.","commonSituations":"Caching layers that add input_ids for reuse but forget to drop text; template rendering code that populates both fields 'for safety'.","solutions":["Drop one field: keep input_ids if you tokenized yourself, otherwise keep text","Set text=None explicitly when building from token ids"],"exampleFix":"// before\nGenerateReqInput(text='hi', input_ids=[1,2,3])\n// after\nGenerateReqInput(input_ids=[1,2,3])","handlingStrategy":"validation","validationCode":"if input_ids is not None:\n    text = None\nassert (text is None) or (input_ids is None)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick exactly one seeding path per request in your client abstraction"],"tags":["sglang","input-conflict","tokenization","request-validation"],"backgroundTag":"conflicting-request-fields","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}