Skip to content

fix(cli): carry registry error codes through every b4 verify phase - #704

Merged
blove merged 1 commit into
mainfrom
blove/verify-carries-error-codes
Sep 17, 2026
Merged

blove merged 1 commit into
mainfrom
blove/verify-carries-error-codes

Conversation

@blove

@blove blove commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Stacked on #701 — base it on main once that merges.

Problem

getFailureCode in packages/cli/src/commands/verify.ts returned a code only when the failing check was runtime. Every other phase returned undefined, so the two codes #701 adds — B4_E1006 (app root package.json is not an ES module) and B4_E1007 (route entry has no recognisable export) — were reachable through verify's app and routes phases but rendered nowhere. b4 check on a broken app printed [B4_E1006] See https://b4.run/docs/cli#b4-check; b4 verify on the same app printed no code, on stderr or in --json.

Change

  • VerifyFailedCheckResult.error widens from { message } to { code?, message }; createVerifyFailureResult populates code when the caught error is a B4AppError and omits the field otherwise (discovery throws plain Errors for the cases with no registry entry).
  • getFailureCode falls through to the failed check's error.code for the non-runtime phases. Runtime keeps its existing sub-check precedence.
  • The failed check is part of the --json payload, so the machine-readable surface picks the code up with it.

Contract change

--json gains an optional error.code on failed checks. Documented under b4 verify's --json flag in apps/web/content/docs/cli.mdx.

The two verify-command.test.ts tests that deep-equal the whole --json payload were checked against the change and neither needed updating: invalid-config fails with defineConfig is not defined (a plain Error) and invalid-companion fails with the multiple exports message, which is also a plain Error — B4_E1007 covers the no recognisable export throw. A new test pins that those payloads stay code-free.

Tests

Four new tests in packages/cli/test/verify-command.test.ts: [B4_E1006] and [B4_E1007] on stderr, error.code === "B4_E1006" in --json, and the code-free payload for an uncoded failure.

pnpm --filter @b4run/cli test — 1891 passed, 4 skipped. Typecheck, biome, check-docs.mjs green; apps/web SEO lastmod manifest regenerated.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
b4-run Ready Ready Preview Sep 17, 2026 8:26pm UTC

Request Review

Base automatically changed from blove/check-commonjs-app-root to main September 17, 2026 17:25
@blove
blove force-pushed the blove/verify-carries-error-codes branch from 05175df to 54ab68f Compare September 17, 2026 18:13
@blove
blove enabled auto-merge (squash) September 17, 2026 18:13
@blove
blove force-pushed the blove/verify-carries-error-codes branch from 54ab68f to 16cb2a1 Compare September 17, 2026 20:18
@blove
blove force-pushed the blove/verify-carries-error-codes branch from 16cb2a1 to 25a781f Compare September 17, 2026 20:22
`getFailureCode` only returned a code for the `runtime` check, so an app
that `b4 check` diagnoses as `[B4_E1006]` or `[B4_E1007]` failed `b4 verify`
with no code at all — on stderr or in `--json`.

`VerifyFailedCheckResult.error` now carries an optional `code`, populated
when the caught error is a `B4AppError`, and `getFailureCode` reads it for
the non-runtime phases. Because the failed check is part of the `--json`
payload, the machine-readable surface carries the code too; the field is
omitted when the underlying failure has no registry entry.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@blove
blove force-pushed the blove/verify-carries-error-codes branch from 25a781f to cad08e3 Compare September 17, 2026 20:26
@blove
blove merged commit 3f32ad8 into main Sep 17, 2026
29 of 30 checks passed
@blove
blove deleted the blove/verify-carries-error-codes branch September 17, 2026 21:31
blove added a commit that referenced this pull request Sep 17, 2026
None of the three touches this page: verify registry error codes,
body-less middleware reject status, and a k8s smoke watchdog. Only the
generated SEO manifest conflicted, resolved by regenerating per the
procedure #712 added to AGENTS.md.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

This branch was successfully deployed

1 active and 1 inactive deployments
vercel-preview — cad08e35 Deployed Sep 17, 2026 by blove via vercel-native #2005
Preview — cad08e35 Deployed Sep 17, 2026 by vercel[bot]
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.

1 participant