{"record":{"id":"dde9e2c0f0942623","repo":"Comfy-Org/ComfyUI","slug":"provide-either-a-background-image-or-a-background","errorCode":null,"errorMessage":"Provide either a background image or a background video, not both.","messagePattern":"Provide either a background image or a background video, not both\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/nodes_bria.py","lineNumber":969,"sourceCode":"                IO.Hidden.api_key_comfy_org,\n                IO.Hidden.unique_id,\n            ],\n            is_api_node=True,\n            price_badge=IO.PriceBadge(\n                expr=\"\"\"{\"type\":\"usd\",\"usd\":0.05,\"format\":{\"suffix\":\"/second\"}}\"\"\",\n            ),\n        )\n\n    @classmethod\n    async def execute(\n        cls,\n        video: Input.Video,\n        seed: int,\n        background_image: Input.Image | None = None,\n        background_video: Input.Video | None = None,\n    ) -> IO.NodeOutput:\n        if (background_image is None) == (background_video is None):\n            raise ValueError(\"Provide either a background image or a background video, not both.\")\n        validate_video_duration(video, max_duration=60.0)\n        if background_video is not None:\n            validate_video_duration(background_video, max_duration=60.0)\n            background_url = await upload_video_to_comfyapi(cls, background_video, wait_label=\"Uploading background\")\n        else:\n            # Bria's replace_background 500s on RGBA, so drop the alpha channel before upload.\n            background_url = await upload_image_to_comfyapi(\n                cls, background_image[:, :, :, :3], wait_label=\"Uploading background\"\n            )\n        response = await sync_op(\n            cls,\n            ApiEndpoint(path=\"/proxy/bria/v2/video/edit/replace_background\", method=\"POST\"),\n            data=BriaVideoReplaceBackgroundRequest(\n                video=await upload_video_to_comfyapi(cls, video),\n                background_url=background_url,\n                output_container_and_codec=\"mp4_h264\",\n                seed=seed,\n            ),","sourceCodeStart":951,"sourceCodeEnd":987,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/nodes_bria.py#L951-L987","documentation":"Bria's video replace-background endpoint takes exactly one background source. The node models this as two optional inputs (background_image, background_video) and enforces XOR: providing both, or neither, raises this error before any upload.","triggerScenarios":"(background_image is None) == (background_video is None) evaluates true - both connected, or both left empty.","commonSituations":"User wires both inputs 'to be safe'; or copies the node into a workflow and connects neither, assuming a transparent/default background exists.","solutions":["Connect exactly one of background_image or background_video.","If you want the original (no replacement), this is the wrong node - remove it.","Note: RGBA background images have alpha dropped before upload because Bria 500s on RGBA."],"exampleFix":"// before\nbackground_image: img, background_video: vid\n// after\nbackground_image: img, background_video: null","handlingStrategy":"validation","validationCode":"if (background_image is None) == (background_video is None):\n    raise UserError('Connect exactly one of background_image / background_video.')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat the two background inputs as mutually exclusive radio choices in workflow design.","Remember RGB background images are alpha-stripped automatically; do not pre-compose alpha expecting it to survive."],"tags":["comfyui","bria","video","validation","input-required"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}