[Partner Nodes] allow custom resolutions for GPTImage2 node#13631
[Partner Nodes] allow custom resolutions for GPTImage2 node#13631Kosinkadink merged 1 commit intomasterfrom
Conversation
📝 WalkthroughWalkthroughAdds a "Custom" size option to the OpenAI GPT Image node and new 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 6/8 reviews remaining, refill in 11 minutes and 2 seconds.Comment |
Signed-off-by: bigcat88 <bigcat88@icloud.com>
148c175 to
3901489
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@comfy_api_nodes/nodes_openai.py`:
- Around line 539-544: The validation for custom image dimensions can raise
ZeroDivisionError when custom_width or custom_height is 0; before performing
modulus or computing ratio, add an explicit positivity check for custom_width
and custom_height (e.g., if custom_width <= 0 or custom_height <= 0: raise
ValueError("Custom width and height must be positive integers, got
{custom_width}x{custom_height}")), then proceed with the existing checks that
use custom_width % 16, custom_height % 16 and compute ratio; update the
validation block around the custom_width/custom_height/ratio logic in
nodes_openai.py accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 974007cd-8df2-49f1-b858-bcd500cc5b72
📒 Files selected for processing (1)
comfy_api_nodes/nodes_openai.py
| if custom_width % 16 != 0 or custom_height % 16 != 0: | ||
| raise ValueError(f"Custom width and height must be multiples of 16, got {custom_width}x{custom_height}") | ||
| if max(custom_width, custom_height) > 3840: | ||
| raise ValueError(f"Custom resolution max edge must be <= 3840, got {custom_width}x{custom_height}") | ||
| ratio = max(custom_width, custom_height) / min(custom_width, custom_height) | ||
| if ratio > 3: |
There was a problem hiding this comment.
Guard non-positive custom dimensions before aspect-ratio division
The custom-size validation can throw an unhandled ZeroDivisionError on Line 543 when either dimension is 0. Add an explicit positivity check so invalid input consistently returns ValueError.
Suggested fix
if size == "Custom":
if model != "gpt-image-2":
raise ValueError("Custom resolution is only supported by GPT Image 2 model")
+ if custom_width <= 0 or custom_height <= 0:
+ raise ValueError(
+ f"Custom width and height must be positive integers, got {custom_width}x{custom_height}"
+ )
if custom_width % 16 != 0 or custom_height % 16 != 0:
raise ValueError(f"Custom width and height must be multiples of 16, got {custom_width}x{custom_height}")🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@comfy_api_nodes/nodes_openai.py` around lines 539 - 544, The validation for
custom image dimensions can raise ZeroDivisionError when custom_width or
custom_height is 0; before performing modulus or computing ratio, add an
explicit positivity check for custom_width and custom_height (e.g., if
custom_width <= 0 or custom_height <= 0: raise ValueError("Custom width and
height must be positive integers, got {custom_width}x{custom_height}")), then
proceed with the existing checks that use custom_width % 16, custom_height % 16
and compute ratio; update the validation block around the
custom_width/custom_height/ratio logic in nodes_openai.py accordingly.
|
In the long term, using DynamicCombo would allow for the custom width/height to appear only when custom is selected, but that can be done with node replacement when we feel like it. |
API Node PR Checklist
Scope
Pricing & Billing
If Need pricing update:
QA
Comms