{"record":{"id":"be7ff6f1dd449172","repo":"Comfy-Org/ComfyUI","slug":"custom-size-out-of-range-w-x-h-both-width-and","errorCode":null,"errorMessage":"Custom size out of range: {w}x{h}. Both width and height must be between 512 and 2048 pixels.","messagePattern":"Custom size out of range: (.+?)x(.+?)\\. Both width and height must be between 512 and 2048 pixels\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/nodes_bytedance.py","lineNumber":535,"sourceCode":"        prompt: str,\n        size_preset: str,\n        width: int,\n        height: int,\n        seed: int,\n        guidance_scale: float,\n        watermark: bool,\n    ) -> IO.NodeOutput:\n        validate_string(prompt, strip_whitespace=True, min_length=1)\n        w = h = None\n        for label, tw, th in RECOMMENDED_PRESETS:\n            if label == size_preset:\n                w, h = tw, th\n                break\n\n        if w is None or h is None:\n            w, h = width, height\n            if not (512 <= w <= 2048) or not (512 <= h <= 2048):\n                raise ValueError(\n                    f\"Custom size out of range: {w}x{h}. \" \"Both width and height must be between 512 and 2048 pixels.\"\n                )\n\n        payload = Text2ImageTaskCreationRequest(\n            model=model,\n            prompt=prompt,\n            size=f\"{w}x{h}\",\n            seed=seed,\n            guidance_scale=guidance_scale,\n            watermark=watermark,\n        )\n        response = await sync_op(\n            cls,\n            ApiEndpoint(path=BYTEPLUS_IMAGE_ENDPOINT, method=\"POST\"),\n            data=payload,\n            response_model=ImageTaskCreationResponse,\n        )\n        return IO.NodeOutput(await download_url_to_image_tensor(get_image_url_from_response(response)))","sourceCodeStart":517,"sourceCodeEnd":553,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/nodes_bytedance.py#L517-L553","documentation":"ByteDance text-to-image: when size_preset does not match any RECOMMENDED_PRESETS label, the node falls back to the custom width/height widgets and requires both to be within 512-2048 pixels (the API's accepted range for this endpoint).","triggerScenarios":"size_preset widget set to a custom entry (or stale label not in RECOMMENDED_PRESETS) and width or height outside [512, 2048], e.g. 256 or 4096.","commonSituations":"Hand-edited workflow JSON with a size label that no longer exists after a node update (falls through to custom values); user types 4096 hoping for 4K on an endpoint capped at 2048.","solutions":["Set width and height widgets to values in [512, 2048].","Or pick a recommended preset label that exists in the current widget list.","For larger outputs, use the Seedream node (which allows up to ~16MP) instead of this text-to-image endpoint."],"exampleFix":"// before\nsize_preset: 'custom', width: 4096, height: 4096\n// after\nsize_preset: 'custom', width: 2048, height: 2048","handlingStrategy":"validation","validationCode":"if size_preset not in PRESET_LABELS:\n    assert 512 <= width <= 2048 and 512 <= height <= 2048, 'custom size must be 512-2048'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer preset labels over custom sizes; they survive node updates.","Clamp custom width/height widgets to [512, 2048] when building workflows programmatically."],"tags":["comfyui","bytedance","image-size","limits","validation"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}