Skip to content

Propagate CLI subprocess exit code#55

Merged
eggplants merged 5 commits into
OpenAPITools:masterfrom
mxr:propagate-cli-exit-code
Apr 30, 2026
Merged

Propagate CLI subprocess exit code#55
eggplants merged 5 commits into
OpenAPITools:masterfrom
mxr:propagate-cli-exit-code

Conversation

@mxr
Copy link
Copy Markdown
Contributor

@mxr mxr commented Apr 29, 2026

Problem

The console script currently discards the return code from the Java subprocess. That means callers can see a successful Python CLI exit even when Java fails.

Solution

Exit from the console entry point with the subprocess return code. Add a regression test that verifies the CLI propagates a non-zero result.


Summary by cubic

Propagate the Java subprocess exit code from the openapi-generator-cli entrypoint so callers and CI fail correctly. cli now accepts argv and defaults to sys.argv to preserve behavior and simplify testing.

  • Bug Fixes
    • Exit with the Java return code via sys.exit(run(args).returncode) and parse args as (argv or sys.argv)[1:].
    • Add tests for run([...]) and cli([...]) to assert non-zero exit codes, error message, and no stdout on invalid args.
    • Document the cli(argv) argument and default behavior in the docstring.

Written for commit 44495ec. Summary will update on new commits. Review in cubic

@mxr mxr marked this pull request as ready for review April 29, 2026 13:00
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Comment thread tests/test_cli.py
@mxr mxr force-pushed the propagate-cli-exit-code branch from a8c6bdc to 1be73c0 Compare April 29, 2026 19:44
@mxr mxr requested a review from eggplants April 29, 2026 19:55
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tests/test_cli.py">

<violation number="1" location="tests/test_cli.py:48">
P2: Replacing the dedicated CLI exit-code test with another invalid-argument test drops coverage for `cli()` propagating `run(...).returncode`.</violation>
</file>

<file name="openapi_generator_cli/__init__.py">

<violation number="1" location="openapi_generator_cli/__init__.py:61">
P1: Console-script entry point will drop all user CLI arguments because `cli()` now falls back to `[]` when invoked without argv.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread openapi_generator_cli/__init__.py Outdated
Comment thread tests/test_cli.py
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="openapi_generator_cli/__init__.py">

<violation number="1" location="openapi_generator_cli/__init__.py:61">
P2: `cli([])` now falls back to `sys.argv` instead of honoring the caller-provided empty argv, changing public API behavior and potentially propagating unrelated process arguments.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread openapi_generator_cli/__init__.py Outdated
Comment thread openapi_generator_cli/__init__.py
@mxr mxr requested a review from eggplants April 29, 2026 20:28
eggplants

This comment was marked as outdated.

@eggplants eggplants requested a review from wing328 April 29, 2026 20:30
Comment thread openapi_generator_cli/__init__.py Outdated
@eggplants eggplants merged commit e0d8231 into OpenAPITools:master Apr 30, 2026
2 of 8 checks passed
@eggplants eggplants removed the request for review from wing328 April 30, 2026 09:38
@mxr mxr deleted the propagate-cli-exit-code branch May 1, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants