{"record":{"id":"678eecdd7889740e","repo":"sgl-project/sglang","slug":"provide-either-prompt-or-prompt-embeds-cannot","errorCode":null,"errorMessage":"Provide either `prompt` or `prompt_embeds`. Cannot leave both `prompt` and `prompt_embeds` undefined.","messagePattern":"Provide either `prompt` or `prompt_embeds`\\. Cannot leave both `prompt` and `prompt_embeds` undefined\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/glm_image.py","lineNumber":1106,"sourceCode":"            logger.warning(\n                f\"`height` and `width` have to be divisible by {self.vae_scale_factor * 2} but are {height} and {width}. Dimensions will be resized accordingly\"\n            )\n\n        if callback_on_step_end_tensor_inputs is not None and not all(\n            k in self._callback_tensor_inputs\n            for k in callback_on_step_end_tensor_inputs\n        ):\n            raise ValueError(\n                f\"`callback_on_step_end_tensor_inputs` has to be in {self._callback_tensor_inputs}, but found {[k for k in callback_on_step_end_tensor_inputs if k not in self._callback_tensor_inputs]}\"\n            )\n\n        if prompt is not None and prompt_embeds is not None:\n            raise ValueError(\n                f\"Cannot forward both `prompt`: {prompt} and `prompt_embeds`: {prompt_embeds}. Please make sure to\"\n                \" only forward one of the two.\"\n            )\n        elif prompt is None and prompt_embeds is None:\n            raise ValueError(\n                \"Provide either `prompt` or `prompt_embeds`. Cannot leave both `prompt` and `prompt_embeds` undefined.\"\n            )\n        elif prompt is not None and (\n            not isinstance(prompt, str) and not isinstance(prompt, list)\n        ):\n            raise ValueError(\n                f\"`prompt` has to be of type `str` or `list` but is {type(prompt)}\"\n            )\n\n    @property\n    def guidance_scale(self):\n        return self._guidance_scale\n\n    @property\n    def do_classifier_free_guidance(self):\n        return self._guidance_scale > 1\n\n    @property","sourceCodeStart":1088,"sourceCodeEnd":1124,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/glm_image.py#L1088-L1124","documentation":"The counterpart to the both-provided check: the pipeline requires at least one of prompt or prompt_embeds. When both are None there is no conditioning signal at all, so generation cannot proceed and ValueError is raised.","triggerScenarios":"Calling forward()/check_inputs with prompt=None and prompt_embeds=None, e.g. defaulting both to None in a wrapper and forgetting to populate either.","commonSituations":"Generic wrapper code that accepts optional prompt and embeds but forwards Nones; negative-prompt-only invocations where the positive prompt kwarg was accidentally dropped; refactors that renamed the prompt argument.","solutions":["Pass a non-empty prompt string, or supply prompt_embeds computed from your text encoder","Fix wrapper signatures so omitted arguments still resolve to a default prompt","Add a caller-side assert that at least one of the two is provided"],"exampleFix":"# before\npipe(prompt=None, prompt_embeds=None)\n\n# after\npipe(prompt=\"a cat\")  # or pipe(prompt_embeds=encode(\"a cat\"))","handlingStrategy":"validation","validationCode":"if prompt is None and prompt_embeds is None:\n    raise ValueError(\"provide prompt or prompt_embeds before calling the pipeline\")","typeGuard":"def has_conditioning(prompt, prompt_embeds) -> bool:\n    return prompt is not None or prompt_embeds is not None","tryCatchPattern":"except ValueError as e:\n    if \"Cannot leave both\" in str(e):\n        pipe(prompt=default_prompt)\n    else:\n        raise","preventionTips":["Default prompt to a non-None value in wrapper functions","Assert conditioning exists before invoking the pipeline","Add typing with a Literal/union that makes the None/None case unrepresentable"],"tags":["glm-image","prompt-embeds","required-argument","input-validation","valueerror"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}