Skip to content

fix: propagate InputError instead of returning empty array#3995

Open
pullfrog[bot] wants to merge 3 commits into
mainfrom
pullfrog/3994-fix-input-error-exit-code
Open

fix: propagate InputError instead of returning empty array#3995
pullfrog[bot] wants to merge 3 commits into
mainfrom
pullfrog/3994-fix-input-error-exit-code

Conversation

@pullfrog

@pullfrog pullfrog Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #3994

When the CLI encounters a missing input file, createClient catches the InputError, prints the error message via printCrashReport, and then returns [] instead of re-throwing. The CLI .action() handler sees an empty context, determines no watch mode is active, and calls process.exit(0), silently succeeding from CI's perspective.

This changes the catch block in both openapi-ts/src/generate.ts and openapi-python/src/generate.ts to re-throw InputError instead of returning an empty array. The error propagates up to the CLI's .action() handler, which rejects the promise, and runCli() catches it and calls process.exit(1).

Pullfrog  | View workflow run | via Pullfrog | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

When the input file is missing, generate.ts was catching InputError,
printing the error, and returning [] instead of re-throwing. The CLI's
.action() handler then saw an empty context and called process.exit(0),
masking the failure from CI tooling.

Fix: change `if (inputError) return []` to `if (inputError) throw error`
in both openapi-ts and openapi-python generate.ts files.
@pullfrog pullfrog Bot requested a review from mrlubos June 5, 2026 22:12
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@changeset-bot

changeset-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b771dae

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hey-api/openapi-ts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
web Ready Ready Preview, Comment Jun 6, 2026 1:10am

Request Review

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 5, 2026
@dosubot dosubot Bot added the bug 🔥 Broken or incorrect behavior. label Jun 5, 2026
@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.08%. Comparing base (12366ad) to head (b771dae).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3995   +/-   ##
=======================================
  Coverage   39.07%   39.08%           
=======================================
  Files         610      610           
  Lines       21561    21560    -1     
  Branches     6348     6361   +13     
=======================================
  Hits         8426     8426           
  Misses      10697    10697           
+ Partials     2438     2437    -1     
Flag Coverage Δ
unittests 39.08% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new

pkg-pr-new Bot commented Jun 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

@hey-api/codegen-core

npm i https://pkg.pr.new/@hey-api/codegen-core@3995

@hey-api/json-schema-ref-parser

npm i https://pkg.pr.new/@hey-api/json-schema-ref-parser@3995

@hey-api/nuxt

npm i https://pkg.pr.new/@hey-api/nuxt@3995

@hey-api/openapi-ts

npm i https://pkg.pr.new/@hey-api/openapi-ts@3995

@hey-api/shared

npm i https://pkg.pr.new/@hey-api/shared@3995

@hey-api/spec-types

npm i https://pkg.pr.new/@hey-api/spec-types@3995

@hey-api/types

npm i https://pkg.pr.new/@hey-api/types@3995

@hey-api/vite-plugin

npm i https://pkg.pr.new/@hey-api/vite-plugin@3995

commit: b771dae

@mrlubos

mrlubos commented Jun 6, 2026

Copy link
Copy Markdown
Member

@pullfrog can you locate the commit/pull request where we previously added this handling for input errors? It seems very deliberate.

@pullfrog

pullfrog Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

Found it. The if (inputError) return [] handling was added in commit b643d7d40 ("fix: improve invalid input error") by @mrlubos on 2026-04-02 via PR #3679, which closed issue #3659 ("Disable crash report for not found input").

That PR was quite deliberate — it introduced the InputError class, the getInputError() helper, the printCrashReport handling for input/file-not-found errors (with user-friendly troubleshooting tips), and the return [] early-exit path for both openapi-ts and openapi-python. The intent was to suppress crash reports for known/preventable input errors. The side effect (silent exit code 0) is what PR #3995 now fixes by changing return []throw error.

Task list (3/3 completed)
  • Checkout PR branch and understand the code in question
  • Run git archaeology to find commit where input error handling was added
  • Report findings via report_progress

Pullfrog  | View workflow run | via Pullfrog | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@mrlubos

mrlubos commented Jun 6, 2026

Copy link
Copy Markdown
Member

@pullfrog in that case a cleaner fix is simply removing that line, no? We throw after anyway

@pullfrog

pullfrog Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

Removed the redundant if (inputError) throw error; lines from both packages/openapi-ts/src/generate.ts and packages/openapi-python/src/generate.ts. The unconditional throw error on the very next line handles both input errors and other errors, making the conditional dead code. Pushed as 0d6d8ae.

Task list (5/5 completed)

Pullfrog  | View workflow run | via Pullfrog | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🔥 Broken or incorrect behavior. lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI returns successful (exit code 0) when input file is missing

1 participant