Skip to content

fix(core): report every unrecognised route entry in one run - #705

Merged
blove merged 1 commit into
mainfrom
blove/zen-roentgen-ff0492
Sep 17, 2026
Merged

blove merged 1 commit into
mainfrom
blove/zen-roentgen-ff0492

Conversation

@blove

@blove blove commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #701.

Problem

#701 added B4_E1007 for a route index.ts that exports nothing B4.run recognises, but the throw happens inside the recursive walkRouteTree. An app with several miswired route entries surfaces them one per run: the user fixes one, re-runs, meets the next.

That is inconsistent with this repo's own convention for b4 check diagnostics, which deliberately batch — the edge-capability gate in packages/cli/src/commands/check.ts reports every offending config key and file at once as B4_E1005, and marker-files.ts names every oversized marker file across all routes in one failed build.

Change

packages/core/src/discovery/discover-routes.ts:

  • readRouteEntry no longer throws. It returns a RouteEntryScan — { route }, { unrecognised }, or neither — mirroring the scanRouteMarkerFiles shape that collects findings without throwing so a caller can aggregate them.
  • walkRouteTree threads an unrecognised[] accumulator alongside discovered[].
  • collectRouteDefinitions throws once at the end, before the collision check.
  • New explainUnrecognisedRouteEntries builds the message. One entry returns its existing message byte-for-byte, so the single-file UX and every current assertion are untouched; several are bulleted with their per-entry explanations indented underneath. Order is walk order, which is stable because readdir is already sorted.

The B4_E1007 code and the per-file message from explainUnrecognisedRouteExports are unchanged.

Rendered from the built CLI path:

2 route entries have no recognisable export:
  • Route entry /…/src/app/other/index.ts has no recognisable export (found: unrelated).
    A route index.ts must export a default export of `agent(...)`, or exactly one of "agent", "workflow", "graph", or "chain".
    If this directory is not a route, prefix its name with "_" to keep it out of route discovery.
  • Route entry /…/src/app/util/index.ts has no recognisable export (found: helper).
    A route index.ts must export a default export of `agent(...)`, or exactly one of "agent", "workflow", "graph", or "chain".
    If this directory is not a route, prefix its name with "_" to keep it out of route discovery.

Tests

New case in packages/core/test/discover-routes.test.ts with two bad route entries, asserting both paths and both export names appear in one B4AppError carrying B4_E1007.

Docs and #701's changeset get a sentence each — the batching is part of the same unreleased behaviour, so it does not warrant a second changeset.

Verification

Gate Result
@b4run/core tests 47 files, 542 passed (discover-routes.test.ts 18/18)
@b4run/cli tests 160 files, 1820 passed, 4 skipped — includes check-command.test.ts 12/12 with the built-CLI subprocess test
@b4run/sdk tests 111 passed
@b4run/web tests 631 passed
pnpm lint / pnpm typecheck 28 / 53 tasks green

Editing cli.mdx staled lastmod.generated.json; regenerated with --as-of 2026-09-17.

🤖 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:00pm UTC

Request Review

@github-actions github-actions Bot 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.

Automated approval: this PR received an intelligent (AI) code review. See the review comments on this PR.

@blove
blove enabled auto-merge (squash) September 17, 2026 18:13
Route discovery threw B4_E1007 from inside the recursive walk, so an app
with several miswired route entries surfaced them one per run: fix one,
re-run, meet the next. The walk now records each unrecognised entry and
throws once at the end, listing every offending file with its own
explanation — the same batching `b4 check`'s edge-capability gate and the
marker-file limits already use.

The code and the per-file message are unchanged; a single offending entry
still produces exactly the message it did before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@blove
blove force-pushed the blove/zen-roentgen-ff0492 branch from 7b9c810 to f968e3a Compare September 17, 2026 19:59
@blove
blove merged commit a74e71e into main Sep 17, 2026
28 of 30 checks passed
@blove
blove deleted the blove/zen-roentgen-ff0492 branch September 17, 2026 20:17
blove added a commit that referenced this pull request Sep 17, 2026
Only the generated SEO lastmod manifest conflicted with #705;
regenerated rather than hand-merged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
blove added a commit that referenced this pull request Sep 17, 2026
Neither change affects this page. #705 batches route-discovery errors,
and #708 is the edge page's own local-run recipe switching from /healthz
to /readyz for the same reason this guide already did.

#691 was closed unmerged, so the emitted function directory is still
index.func and this page's shadowing argument stands unchanged.

Only the lastmod manifest conflicted; regenerated.

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

This branch was successfully deployed

1 active and 1 inactive deployments
vercel-preview — f968e3aa Deployed Sep 17, 2026 by blove via vercel-native #1993
Preview — f968e3aa 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