{"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/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/image_edit/amazon_nova_canvas_image_edit_transformation.py#L79-L115","documentation":"The Nova Canvas image-edit transformation only accepts taskType values BACKGROUND_REMOVAL, OUTPAINTING, IMAGE_VARIATION, and INPAINTING (or no taskType for automatic routing). Any other non-empty taskType reaching the final validation branch raises this ValueError listing the allowed values.","triggerScenarios":"Passing taskType values valid for Nova text-to-image but not edits (e.g. 'COLOR_GUIDED_GENERATION', 'TEXT_IMAGE'), or casing/typo variants like 'inpainting', 'Inpainting', 'WATERMARK' in an images/edits call on a nova-canvas model.","commonSituations":"Copy-pasting a taskType from a Nova Canvas image-generation payload into an image-edit request; assuming the generation taskType enum applies to edits; sending whitespace-padded values is tolerated but wrong casing is not.","solutions":["Set taskType to one of BACKGROUND_REMOVAL, OUTPAINTING, IMAGE_VARIATION, INPAINTING (exact uppercase), or omit it for auto routing.","For background removal, remember only BACKGROUND_REMOVAL needs no mask and no text prompt requirements differ per task.","If you wanted color-guided generation, use the image-generation endpoint (litellm.image / /v1/images/generations), not /v1/images/edits."],"exampleFix":"# before\noptional_params={\"taskType\": \"COLOR_GUIDED_GENERATION\"}  # edits -> ValueError\n# after\noptional_params={\"taskType\": \"INPAINTING\", \"maskPrompt\": \"the sky\"}\n# or omit taskType entirely","handlingStrategy":"validation","validationCode":"EDIT_TASK_TYPES = {\"BACKGROUND_REMOVAL\", \"OUTPAINTING\", \"IMAGE_VARIATION\", \"INPAINTING\"}\n\ndef valid_edit_task_type(tt: str | None) -> bool:\n    return tt is None or (isinstance(tt, str) and tt.strip() in EDIT_TASK_TYPES or tt in EDIT_TASK_TYPES)","typeGuard":"def is_nova_edit_task_type(tt: object) -> bool:\n    return isinstance(tt, str) and tt in {\n        \"BACKGROUND_REMOVAL\", \"OUTPAINTING\", \"IMAGE_VARIATION\", \"INPAINTING\"\n    }","tryCatchPattern":null,"preventionTips":["Keep an enum/constant set of edit task types and validate against it client-side.","Remember generation taskTypes (COLOR_GUIDED_GENERATION, TEXT_IMAGE) are invalid on /images/edits.","Use exact uppercase strings; casing is not normalized."],"tags":["bedrock","nova-canvas","image-edit","validation","task-type"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}