Skip to content

openai-image-gen: validate and normalize --output-format#36648

Merged
vincentkoc merged 4 commits intoopenclaw:mainfrom
shuofengzhang:fix/openai-image-gen-validate-output-format
Mar 6, 2026
Merged

openai-image-gen: validate and normalize --output-format#36648
vincentkoc merged 4 commits intoopenclaw:mainfrom
shuofengzhang:fix/openai-image-gen-validate-output-format

Conversation

@shuofengzhang
Copy link
Copy Markdown
Contributor

@shuofengzhang shuofengzhang commented Mar 5, 2026

What changed

  • Added normalize_output_format() in skills/openai-image-gen/scripts/gen.py to normalize and validate --output-format for GPT image models.
  • Normalized jpg to jpeg for user convenience.
  • Warned and ignored --output-format when the selected model does not support that flag.
  • Added unit tests for valid pass-through, case normalization, empty-input, invalid-value, and incompatible-model warning paths.
  • Added a changelog entry with contributor attribution.

Why

  • Unsupported values previously failed late with API errors and could produce inconsistent local output behavior.
  • Incompatible models could silently drop the flag, which is confusing CLI behavior.
  • Early validation and explicit warnings make the tool behavior predictable and reduce avoidable runtime failures.

Testing

  • python3 -m ruff check skills/openai-image-gen/scripts/test_gen.py
  • python3 -m pytest -q skills/openai-image-gen/scripts/test_gen.py (11 passed)

Fixes #36649

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 5, 2026

Greptile Summary

This PR adds normalize_output_format() to skills/openai-image-gen/scripts/gen.py to validate and normalize the --output-format CLI argument for gpt-image models. The change is well-scoped, logically correct, and fits naturally into the existing pre-flight validation pattern.

Key strengths:

  • jpg is correctly aliased to jpeg as a user convenience.
  • Unsupported formats raise a ValueError caught in main() and returned as exit code 2, consistent with other early-exit error handling.
  • The normalized value is applied consistently to both the API request payload and the output filename extension.

Minor test gaps:

  • Valid format pass-through ("png""png", etc.), case normalization ("PNG""png"), and empty-string cases for gpt-image models lack test coverage. These should be added to prevent regressions.

Confidence Score: 4/5

  • Safe to merge. The core validation logic is correct with no regressions; minor test gaps are non-blocking.
  • The implementation is sound and integrates cleanly with existing error handling. Valid-format pass-through tests are missing, which represents a coverage gap but not a correctness issue. The critical paths (invalid-value rejection, jpg→jpeg aliasing, non-gpt-image passthrough) are tested.
  • skills/openai-image-gen/scripts/test_gen.py - add tests for valid format pass-through scenarios

Last reviewed commit: 4189b01

@vincentkoc vincentkoc force-pushed the fix/openai-image-gen-validate-output-format branch from c619daa to de7f8e0 Compare March 6, 2026 15:55
@vincentkoc vincentkoc self-assigned this Mar 6, 2026
@vincentkoc
Copy link
Copy Markdown
Member

Pushed a follow-up cleanup to this branch.

The diff now includes the added pass-through / empty-input coverage, warning coverage for incompatible models, a changelog entry with attribution, and the Python import-order fix that was tripping skills-python. I reran python3 -m ruff check skills/openai-image-gen/scripts/test_gen.py and python3 -m pytest -q skills/openai-image-gen/scripts/test_gen.py locally before pushing.

@vincentkoc vincentkoc force-pushed the fix/openai-image-gen-validate-output-format branch from c5bff22 to 3bb32a9 Compare March 6, 2026 16:07
@vincentkoc
Copy link
Copy Markdown
Member

Rebased this branch onto current main after #36762 merged.

The overlap in gen.py, test_gen.py, and the changelog is resolved on the new head. The validation path now uses one shared helper for --background, --style, and --output-format, keeps the explicit warning behavior for incompatible models, preserves the changelog attribution, and keeps the targeted test coverage on the rebased diff.

Local verification on the rebased branch:

  • python3 -m ruff check skills/openai-image-gen/scripts/gen.py skills/openai-image-gen/scripts/test_gen.py
  • python3 -m pytest -q skills/openai-image-gen/scripts/test_gen.py (22 passed)

@vincentkoc vincentkoc merged commit 81f22ae into openclaw:main Mar 6, 2026
9 checks passed
ant1eicher pushed a commit to ant1eicher/openclaw that referenced this pull request Mar 6, 2026
)

* openai-image-gen: validate and normalize output format

* Skills/openai-image-gen: cover output-format edge cases

* Changelog: note openai image output format validation

---------

Co-authored-by: Vincent Koc <[email protected]>
Saitop pushed a commit to NomiciAI/openclaw that referenced this pull request Mar 8, 2026
)

* openai-image-gen: validate and normalize output format

* Skills/openai-image-gen: cover output-format edge cases

* Changelog: note openai image output format validation

---------

Co-authored-by: Vincent Koc <[email protected]>
jenawant pushed a commit to jenawant/openclaw that referenced this pull request Mar 10, 2026
)

* openai-image-gen: validate and normalize output format

* Skills/openai-image-gen: cover output-format edge cases

* Changelog: note openai image output format validation

---------

Co-authored-by: Vincent Koc <[email protected]>
dhoman pushed a commit to dhoman/chrono-claw that referenced this pull request Mar 11, 2026
)

* openai-image-gen: validate and normalize output format

* Skills/openai-image-gen: cover output-format edge cases

* Changelog: note openai image output format validation

---------

Co-authored-by: Vincent Koc <[email protected]>
senw-developers pushed a commit to senw-developers/va-openclaw that referenced this pull request Mar 17, 2026
)

* openai-image-gen: validate and normalize output format

* Skills/openai-image-gen: cover output-format edge cases

* Changelog: note openai image output format validation

---------

Co-authored-by: Vincent Koc <[email protected]>
V-Gutierrez pushed a commit to V-Gutierrez/openclaw-vendor that referenced this pull request Mar 17, 2026
)

* openai-image-gen: validate and normalize output format

* Skills/openai-image-gen: cover output-format edge cases

* Changelog: note openai image output format validation

---------

Co-authored-by: Vincent Koc <[email protected]>
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 20, 2026
)

Co-authored-by: Vincent Koc <[email protected]>
(cherry picked from commit 81f22ae1095fca18e1b61425a5b73b2deda2e1a5)
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 20, 2026
)

Co-authored-by: Vincent Koc <[email protected]>
(cherry picked from commit 81f22ae1095fca18e1b61425a5b73b2deda2e1a5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openai-image-gen: validate and normalize unsupported --output-format values

2 participants