{"record":{"id":"fc73a68afe95b709","repo":"BerriAI/litellm","slug":"amazon-nova-canvas-task-type-requires-a-text-pro","errorCode":null,"errorMessage":"Amazon Nova Canvas {task_type} requires a text prompt. Pass a non-empty `prompt` in your request.","messagePattern":"Amazon Nova Canvas (.+?) requires a text prompt\\. Pass a non-empty `prompt` in your request\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/image_edit/amazon_nova_canvas_image_edit_transformation.py","lineNumber":352,"sourceCode":"        if width is not None:\n            image_generation_config[\"width\"] = width\n        if height is not None:\n            image_generation_config[\"height\"] = height\n        if number_of_images is not None:\n            image_generation_config[\"numberOfImages\"] = number_of_images\n        if quality is not None:\n            image_generation_config[\"quality\"] = quality\n        if cfg_scale is not None:\n            image_generation_config[\"cfgScale\"] = cfg_scale\n        if seed is not None:\n            image_generation_config[\"seed\"] = seed\n\n        task_type: Final = op.pop(\"taskType\", None)\n        if (prompt is None or prompt == \"\") and task_type in (\n            \"INPAINTING\",\n            \"OUTPAINTING\",\n        ):\n            raise ValueError(\n                f\"Amazon Nova Canvas {task_type} requires a text prompt. Pass a non-empty `prompt` in your request.\"\n            )\n        text: Final = prompt if prompt is not None and prompt != \"\" else \" \"\n        negative_text: Final = op.pop(\"negativeText\", None)\n        similarity_strength: Final = op.pop(\"similarityStrength\", None)\n        mask_prompt: Final = op.pop(\"maskPrompt\", None)\n        out_painting_mode: Final = op.pop(\"outPaintingMode\", None)\n\n        body: Final = _nova_canvas_task_body(\n            image_b64=image_b64,\n            mask_b64=mask_b64,\n            text=text,\n            negative_text=negative_text,\n            similarity_strength=similarity_strength,\n            task_type=task_type,\n            mask_prompt=mask_prompt,\n            out_painting_mode=out_painting_mode,\n        )","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/image_edit/amazon_nova_canvas_image_edit_transformation.py#L334-L370","documentation":"AWS requires a non-empty text prompt for Nova Canvas INPAINTING and OUTPAINTING tasks (the prompt describes the edit to apply inside/outside the mask). LiteLLM checks this after popping taskType; for other task types an empty prompt is silently replaced with a single space, but for these two it raises before building the body.","triggerScenarios":"taskType='INPAINTING' or 'OUTPAINTING' with prompt=None or prompt='' in litellm.image_edit (e.g. mask-only call with no edit instruction).","commonSituations":"Assuming the mask alone drives the edit; prompt variables rendered empty by templating/i18n; code paths that pass '' as a placeholder.","solutions":["Pass a descriptive non-empty prompt, e.g. prompt='fill the masked area with foliage'","If you only want background removal, use taskType='BACKGROUND_REMOVAL', which needs no prompt","Guard prompt construction: prompt = user_text or default_edit_instruction"],"exampleFix":"# before\nresp = litellm.image_edit(\n    model=\"bedrock/amazon.nova-canvas-v1:0\",\n    image=open(\"cat.png\", \"rb\"),\n    mask=open(\"mask.png\", \"rb\"),\n    taskType=\"INPAINTING\",\n    prompt=\"\",\n)\n\n# after\nresp = litellm.image_edit(\n    model=\"bedrock/amazon.nova-canvas-v1:0\",\n    image=open(\"cat.png\", \"rb\"),\n    mask=open(\"mask.png\", \"rb\"),\n    taskType=\"INPAINTING\",\n    prompt=\"replace the masked area with flowers\",\n)","handlingStrategy":"validation","validationCode":"PROMPT_REQUIRED_TASKS = {\"INPAINTING\", \"OUTPAINTING\"}\nif kwargs.get(\"taskType\") in PROMPT_REQUIRED_TASKS and not (prompt or \"\").strip():\n    raise ValueError(\"INPAINTING/OUTPAINTING need a non-empty prompt\")","typeGuard":"def has_required_prompt(task_type: str | None, prompt: str | None) -> bool:\n    \"\"\"True when the prompt satisfies the task's requirement.\"\"\"\n    if task_type in (\"INPAINTING\", \"OUTPAINTING\"):\n        return bool(prompt and prompt.strip())\n    return True","tryCatchPattern":"try:\n    resp = litellm.image_edit(...)\nexcept ValueError as e:\n    if \"requires a text prompt\" in str(e):\n        raise UserInputError(\"Describe the edit you want applied to the masked area\") from e\n    raise","preventionTips":["Default empty prompts to a task-appropriate instruction string in your UI layer","Add form validation that blocks empty instructions for mask-based edits","Skip prompt validation only for BACKGROUND_REMOVAL"],"tags":["bedrock","nova-canvas","image-edit","inpainting","outpainting","prompt","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}