Skip to content

fix(build-cli): preserve error exits in quiet mode - #28162

Merged
shlevari merged 2 commits into
microsoft:mainfrom
shlevari:wi74372-basecommand-error
Sep 9, 2026
Merged

fix(build-cli): preserve error exits in quiet mode#28162
shlevari merged 2 commits into
microsoft:mainfrom
shlevari:wi74372-basecommand-error

Conversation

@shlevari

@shlevari shlevari commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes AB#74372.

BaseCommand.error() previously skipped oclif's error handling when --quiet was set. As a result, fatal errors returned normally instead of throwing or applying the requested exit code, allowing commands to continue after a failure.

This change always delegates errors to oclif exactly once while retaining the existing string formatting. Other informational and warning output remains suppressed by --quiet.

A dedicated hidden test command immediately reports an intentional error with exit code 1. Its focused regression test invokes the command with --quiet and verifies that oclif still returns the expected error and exit code.

Reviewer Guidance

The review process is outlined in the pull request guidelines.

Please confirm that fatal errors should preserve oclif's throw and exit behavior regardless of the logging verbosity setting.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added area: tools area: build Build related issues area: repo Repo related work area: website base: main PRs targeted against main branch labels Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Hi! Thank you for opening this PR. Want me to review it?

Based on the diff (52 lines, 3 files), I've queued these reviewers:

  • Correctness — logic errors, race conditions, lifecycle issues
  • Security — vulnerabilities, secret exposure, injection
  • API Compatibility — breaking changes, release tags, type design
  • Performance — algorithmic regressions, memory leaks
  • Testing — coverage gaps, hollow tests

How this works

  • Adjust the reviewer set by ticking/unticking boxes above. Reviewer toggles alone don't trigger anything.

  • Tick Start review below to dispatch the review fleet.

  • After review finishes, tick Start review again to request another run — it auto-resets after each dispatch.

  • This comment updates as new commits land; your reviewer selections are preserved.

  • Start review

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@shlevari
shlevari marked this pull request as ready for review September 8, 2026 22:12
Copilot AI lite review requested due to automatic review settings September 8, 2026 22:12
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Bundle size comparison

Base commit: could not be determined; will be reported when the comparison runs
Head commit: b94799b63ee8656309469a95f7d13b8ebf2c2348

Pending — Build - client packages is running. Results will appear here when the build completes.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

🔭 PR Review Fleet Report

Note

This report is generated by an experimental AI review fleet and is provided as a beta feature. Findings are a starting point for discussion, not a gate. Use your own judgement.

Verdict: ⚠️ Approve with Suggestions

0 Disastrous, 1 Dangerous, 1 Disagreeable

Findings

Sev # Area File What Fix
🐊 Dangerous H1 Testing build-tools/packages/build-cli/src/library/commands/base.ts:276 The new test-only-error.test.ts only exercises the typeof input === "string" branch of error() under --quiet. The other branch (return super.error(input as Error, options as any), line 276), which now also unconditionally calls super.error regardless of suppressLogging, has no test at all — for either an Error-instance input or non-quiet mode. Since the whole point of this change was removing the !this.suppressLogging guard so errors always propagate, a regression that re-adds a guard around only one of the two branches (e.g. if (!this.suppressLogging) return super.error(input as Error, ...)) would still pass the existing test. Add a test command/case that calls this.error(new Error("boom")) (an Error instance, not a string) both with and without --quiet, and assert error?.oclif?.exit and error?.message in both cases to confirm the Error-instance path also always throws/exits.
🐍 Disagreeable M1 Testing build-tools/packages/build-cli/src/library/commands/base.ts:265 Removing the suppressLogging guard changes behavior for the { exit: false } overload of error() (a documented, public overload at line 231-234) too, not just the default-exit case covered by the new test. Previously, calling this.error(msg, { exit: false }) under --quiet was fully suppressed (no super.error call at all, since the outer if (!this.suppressLogging) wrapped the whole method body). Now it always calls super.error(...), which logs the (red-colored) message via oclif even when --quiet is set and does not exit. This is an unverified behavior change: quiet mode may now leak error text to output for non-exiting error calls, contrary to what --quiet implies. Add a test exercising this.error("non-fatal error", { exit: false }) under --quiet and assert whether the message is printed/logged or suppressed, to lock in the intended (documented) behavior for the log-only, non-exiting path under quiet mode.

View workflow run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@shlevari
shlevari merged commit 09abc8d into microsoft:main Sep 9, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: build Build related issues area: repo Repo related work area: tools area: website base: main PRs targeted against main branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants