From b4e6b3a91c28233e189a5da052f5cfb4edf3f891 Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Mon, 27 Jul 2026 23:59:47 -0700 Subject: [PATCH] [Partner Nodes] fix(GPT Image): make custom_width/custom_height optional OpenAIGPTImageNodeV2 declared the gpt-image-2 custom size widgets as required nested inputs, so a prompt that picked a preset size and omitted them failed validation with required_input_missing. execute() already reads both with a 1024 default, and the deprecated OpenAIGPTImage1 node in the same file already marks them optional. --- comfy_api_nodes/nodes_openai.py | 2 ++ .../gpt_image_size_inputs_test.py | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests-unit/comfy_api_test/gpt_image_size_inputs_test.py diff --git a/comfy_api_nodes/nodes_openai.py b/comfy_api_nodes/nodes_openai.py index de2c94353..b91df323c 100644 --- a/comfy_api_nodes/nodes_openai.py +++ b/comfy_api_nodes/nodes_openai.py @@ -747,6 +747,7 @@ class OpenAIGPTImageNodeV2(IO.ComfyNode): max=3840, step=16, tooltip="Used only when `size` is 'Custom'. Must be a multiple of 16.", + optional=True, ), IO.Int.Input( "custom_height", @@ -755,6 +756,7 @@ class OpenAIGPTImageNodeV2(IO.ComfyNode): max=3840, step=16, tooltip="Used only when `size` is 'Custom'. Must be a multiple of 16.", + optional=True, ), IO.Combo.Input( "background", diff --git a/tests-unit/comfy_api_test/gpt_image_size_inputs_test.py b/tests-unit/comfy_api_test/gpt_image_size_inputs_test.py new file mode 100644 index 000000000..04b4d9d30 --- /dev/null +++ b/tests-unit/comfy_api_test/gpt_image_size_inputs_test.py @@ -0,0 +1,27 @@ +from comfy_api.latest._io import get_finalized_class_inputs +from comfy_api_nodes.nodes_openai import OpenAIGPTImageNodeV2 + + +def _finalized_inputs(live_inputs): + class_inputs, _, _ = get_finalized_class_inputs( + OpenAIGPTImageNodeV2.INPUT_TYPES(), live_inputs + ) + return class_inputs + + +def test_gpt_image_2_custom_size_inputs_are_optional(): + """A preset `size` must not require the custom width/height widgets to be present.""" + class_inputs = _finalized_inputs({"model": "gpt-image-2", "model.size": "1536x1024"}) + + assert "model.custom_width" not in class_inputs["required"] + assert "model.custom_height" not in class_inputs["required"] + assert "model.custom_width" in class_inputs["optional"] + assert "model.custom_height" in class_inputs["optional"] + assert "model.size" in class_inputs["required"] + + +def test_gpt_image_legacy_models_have_no_custom_size_inputs(): + for model in ("gpt-image-1", "gpt-image-1.5"): + class_inputs = _finalized_inputs({"model": model, "model.size": "1536x1024"}) + assert "model.custom_width" not in class_inputs["required"] + assert "model.custom_width" not in class_inputs["optional"]