{"record":{"id":"f718b9fcd87f7048","repo":"BerriAI/litellm","slug":"unsupported-amazon-nova-canvas-tasktype-task-typ","errorCode":null,"errorMessage":"Unsupported Amazon Nova Canvas taskType: {task_type!r}. Use BACKGROUND_REMOVAL, OUTPAINTING, IMAGE_VARIATION, INPAINTING, or omit taskType for automatic routing (mask → INPAINTING, else IMAGE_VARIATION).","messagePattern":"Unsupported Amazon Nova Canvas taskType: (.+?)\\. Use BACKGROUND_REMOVAL, OUTPAINTING, IMAGE_VARIATION, INPAINTING, or omit taskType for automatic routing \\(mask → INPAINTING, else IMAGE_VARIATION\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/image_edit/amazon_nova_canvas_image_edit_transformation.py","lineNumber":97,"sourceCode":"    # Honour explicit IMAGE_VARIATION even when a mask is present (mask is ignored\n    # for this task type; callers use INPAINTING when they want mask semantics).\n    if task_type == \"IMAGE_VARIATION\":\n        var_params_explicit: Final[dict[str, Any]] = {\n            \"images\": [image_b64],\n            \"text\": text,\n        }\n        if negative_text is not None:\n            var_params_explicit[\"negativeText\"] = negative_text\n        if similarity_strength is not None:\n            var_params_explicit[\"similarityStrength\"] = similarity_strength\n        return {\n            \"taskType\": \"IMAGE_VARIATION\",\n            \"imageVariationParams\": var_params_explicit,\n        }\n    # Explicit taskType must be INPAINTING or omitted from here on; anything else is invalid.\n    if task_type is not None and str(task_type).strip() != \"\":\n        if task_type != \"INPAINTING\":\n            raise ValueError(\n                f\"Unsupported Amazon Nova Canvas taskType: {task_type!r}. \"\n                \"Use BACKGROUND_REMOVAL, OUTPAINTING, IMAGE_VARIATION, INPAINTING, \"\n                \"or omit taskType for automatic routing (mask → INPAINTING, else IMAGE_VARIATION).\"\n            )\n    if mask_b64 is not None or mask_prompt is not None or task_type == \"INPAINTING\":\n        in_params: Final[dict[str, Any]] = {\"image\": image_b64, \"text\": text}\n        if mask_prompt is not None:\n            in_params[\"maskPrompt\"] = mask_prompt\n        elif mask_b64 is not None:\n            in_params[\"maskImage\"] = mask_b64\n        if negative_text is not None:\n            in_params[\"negativeText\"] = negative_text\n        if \"maskPrompt\" not in in_params and \"maskImage\" not in in_params:\n            raise ValueError(\n                \"Amazon Nova Canvas INPAINTING requires either maskPrompt or maskImage \"\n                \"(use OpenAI mask= for maskImage, or pass maskPrompt in optional params). \"\n                \"See https://docs.aws.amazon.com/nova/latest/userguide/image-gen-req-resp-structure.html\"\n            )","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/image_edit/amazon_nova_canvas_image_edit_transformation.py#L79-L115","documentation":"The Nova Canvas image-edit task body builder only knows four task types: BACKGROUND_REMOVAL, OUTPAINTING, IMAGE_VARIATION, and INPAINTING. After handling the first three, any other non-empty taskType raises this ValueError because there is no matching AWS task params block to construct; an empty/whitespace taskType is treated as omitted (auto-routing).","triggerScenarios":"taskType='COLOR_GUIDED_GENERATION' (a generation-only task), a case mismatch like 'outpainting', or a typo like 'INPAINT' passed to litellm.image_edit with a Nova Canvas model.","commonSituations":"Copying taskType values from the Nova Canvas image-generation docs into an edit call; assuming case-insensitive task names; stale constants after refactoring from generation code to edit code.","solutions":["Use one of the exact uppercase strings: BACKGROUND_REMOVAL, OUTPAINTING, IMAGE_VARIATION, INPAINTING","Omit taskType entirely and let LiteLLM route automatically: mask present -> INPAINTING, otherwise IMAGE_VARIATION","For generation-only tasks (TEXT_IMAGE, COLOR_GUIDED_GENERATION) call litellm.image() instead of litellm.image_edit()"],"exampleFix":"# before\nresp = litellm.image_edit(\n    model=\"bedrock/amazon.nova-canvas-v1:0\",\n    image=open(\"cat.png\", \"rb\"),\n    prompt=\"remove background\",\n    taskType=\"REMOVE_BACKGROUND\",\n)\n\n# after\nresp = litellm.image_edit(\n    model=\"bedrock/amazon.nova-canvas-v1:0\",\n    image=open(\"cat.png\", \"rb\"),\n    prompt=\"remove background\",\n    taskType=\"BACKGROUND_REMOVAL\",\n)","handlingStrategy":"type-guard","validationCode":"SUPPORTED = {\"BACKGROUND_REMOVAL\", \"OUTPAINTING\", \"IMAGE_VARIATION\", \"INPAINTING\"}\ntask = kwargs.get(\"taskType\")\nassert task is None or task in SUPPORTED, f\"bad taskType {task!r}; valid: {SUPPORTED}\"","typeGuard":"from typing import Final\n\nNOVA_CANVAS_EDIT_TASK_TYPES: Final[frozenset[str]] = frozenset(\n    {\"BACKGROUND_REMOVAL\", \"OUTPAINTING\", \"IMAGE_VARIATION\", \"INPAINTING\"}\n)\n\ndef is_valid_edit_task_type(task_type: str | None) -> bool:\n    \"\"\"True when taskType is a Nova Canvas image-edit task or omitted.\"\"\"\n    return task_type is None or str(task_type).strip() == \"\" or task_type in NOVA_CANVAS_EDIT_TASK_TYPES","tryCatchPattern":"try:\n    resp = litellm.image_edit(...)\nexcept ValueError as e:\n    if \"Unsupported Amazon Nova Canvas taskType\" in str(e):\n        # fall back to auto-routing instead of an explicit task\n        kwargs.pop(\"taskType\", None)\n        resp = litellm.image_edit(..., **kwargs)\n    else:\n        raise","preventionTips":["Define task-type constants once and reference them instead of inline strings","Cover the taskType input surface with unit tests asserting membership in the allowed set","Remember generation-only tasks (TEXT_IMAGE, COLOR_GUIDED_GENERATION) belong to litellm.image(), not image_edit()"],"tags":["bedrock","nova-canvas","image-edit","tasktype","routing","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}