Skip to content

fix: hard crash in commands when no API provided#2813

Merged
AlbinaBlazhko17 merged 7 commits into
mainfrom
fix/build-docs-hard-crash
May 14, 2026
Merged

fix: hard crash in commands when no API provided#2813
AlbinaBlazhko17 merged 7 commits into
mainfrom
fix/build-docs-hard-crash

Conversation

@AlbinaBlazhko17
Copy link
Copy Markdown
Contributor

@AlbinaBlazhko17 AlbinaBlazhko17 commented May 14, 2026

What/Why/How?

Fixed a hard crash in build-docs, stats, and score when no API was provided either via the command argument or in the config. These commands — along with bundle, which previously exited silently with no output — now exit with a clear, consistent error message pointing the user to the missing input.

Reference

Testing

Locally

Screenshots (optional)

Before:
Screenshot 2026-05-14 at 11 12 34

After:
Screenshot 2026-05-14 at 14 53 16

Check yourself

  • This PR follows the contributing guide
  • All new/updated code is covered by tests
  • Core code changed? - Tested with other Redocly products (internal contributions only)
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update has been considered

Security

  • The security impact of the change has been considered
  • Code follows company security practices and guidelines

Note

Low Risk
Low risk: centralizes an existing validation case into getFallbackApisOrExit with a clearer message, affecting only CLI argument/config error handling paths.

Overview
Prevents CLI commands that rely on getFallbackApisOrExit from proceeding with an empty API list by making getFallbackApisOrExit exit with a clear, consistent message when neither CLI args nor config define any APIs.

Removes redundant !apis.length checks from lint and scorecard-classic, updates tests accordingly, and adds a changeset for a patch release.

Reviewed by Cursor Bugbot for commit fb35285. Bugbot is set up for automated code reviews on this repo. Configure here.

@AlbinaBlazhko17 AlbinaBlazhko17 self-assigned this May 14, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 14, 2026

🦋 Changeset detected

Latest commit: fb35285

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

This PR includes changesets to release 3 packages
Name Type
@redocly/cli Patch
@redocly/openapi-core Patch
@redocly/respect-core 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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

CLI Version Mean Time ± Std Dev (s) Relative Performance (Lower is Faster)
cli-latest 1.915s ± 0.011s ▓ 1.00x (Fastest)
cli-next 1.934s ± 0.034s ▓ 1.01x

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 80.7% (🎯 80%) 7194 / 8914
🔵 Statements 80.08% (🎯 80%) 7473 / 9331
🔵 Functions 83.68% (🎯 83%) 1436 / 1716
🔵 Branches 72.38% (🎯 72%) 4887 / 6751
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/cli/src/commands/lint.ts 74.46% 50% 50% 74.46% 74-76, 128-157
packages/cli/src/commands/scorecard-classic/index.ts 0% 0% 0% 0% 35-184
packages/cli/src/utils/miscellaneous.ts 61.67% 58.2% 78.04% 60.97% 75, 140, 197-247, 273-274, 284-285, 300, 304, 307, 313, 317-320, 328-361, 372, 397, 406, 414-452, 565, 574
Generated in workflow #9815 for commit a4dd5f8 by the Vitest Coverage Report Action


const apis = await getFallbackApisOrExit(argv.api ? [argv.api] : [], config);

if (!apis.length) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please also look if other commands have the same problem.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

score and stats also hard crashed, when no API's were provided and bundle silently failed. I decided to move exitWithError in getFallbackApisOrExit function.

@AlbinaBlazhko17 AlbinaBlazhko17 marked this pull request as ready for review May 14, 2026 12:00
@AlbinaBlazhko17 AlbinaBlazhko17 requested review from a team as code owners May 14, 2026 12:00
@AlbinaBlazhko17 AlbinaBlazhko17 changed the title fix: hard crash in build-docs command when no API provided fix: hard crash in commands when no API provided May 14, 2026
Comment thread .changeset/tiny-plums-change.md Outdated
Comment thread .changeset/tiny-plums-change.md Outdated
Comment thread packages/cli/src/utils/miscellaneous.ts Outdated
@AlbinaBlazhko17 AlbinaBlazhko17 merged commit 519d4f5 into main May 14, 2026
44 of 45 checks passed
@AlbinaBlazhko17 AlbinaBlazhko17 deleted the fix/build-docs-hard-crash branch May 14, 2026 13:21
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.

3 participants