Skip to content

fix: NOD-002 source fix - middleware returns boolean, nextApiHandler checks before proxy - #45

Merged
mrnicholasbcarter-code merged 2 commits into
masterfrom
fix/nod-002-source-fix
Aug 19, 2026
Merged

fix: NOD-002 source fix - middleware returns boolean, nextApiHandler checks before proxy#45
mrnicholasbcarter-code merged 2 commits into
masterfrom
fix/nod-002-source-fix

Conversation

@mrnicholasbcarter-code

Copy link
Copy Markdown
Owner

Summary

Implements source-level fix for NOD-002: middleware now returns boolean to signal whether the request should continue, and nextApiHandler checks this return value before calling proxy().

Changes

  • src/index.ts:

    • createExpressMiddleware() and createNextMiddleware() now return boolean from inner middleware (true = continue, false = response already written)
    • createNextApiHandler() checks middleware return value before calling proxy(), fixing the fail-open defect where Next.js continued to upstream after 503
  • tests/router.test.ts:

    • Added regression test: "returns 503 and does NOT call upstream when Core decision unavailable (requireCoreDecision=true)" - verifies no upstream fetch when middleware writes 503
    • Added regression test: "returns 503 and does NOT call upstream when middleware rejects request" - verifies fail-closed behavior for validation failures

Validation

  • All 179 tests pass
  • TypeScript build succeeds
  • Typecheck passes
  • verify:package passes
  • Prettier formatting applied

Related

Addresses NOD-002 enforcement gap documented in ADR-001 and node-doc-authority PR #44.

@mrnicholasbcarter-code
mrnicholasbcarter-code merged commit ca53d07 into master Aug 19, 2026
4 checks passed
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