Skip to content

fix: make the nest probe guard able to fail - #21

Merged
ttncode merged 1 commit into
mainfrom
fix/nest-splice-guard
Sep 13, 2026
Merged

ttncode merged 1 commit into
mainfrom
fix/nest-splice-guard

Conversation

@ttncode

@ttncode ttncode commented Sep 13, 2026

Copy link
Copy Markdown
Owner

What this changes

services/shared/nest.sh runs four sed splices over
src/health/health.controller.ts and then verifies them with four greps.
Three of those verify something; the fourth could not fail.

&& grep -q "return { status: 'ok' };" src/health/health.controller.ts \

adapters/nestjs/src/health/health.controller.ts:14 — the live() handler —
already returns exactly { status: 'ok' }; before any splice runs, and the
grep is unanchored, so it matched the shipped file rather than the splice it
was meant to prove.

That grep guards the splice that replaces
throw new Error('no database is configured for this project') with the success
return. If that one anchor ever drifted while the other three still matched, no
die would fire: the generated controller would carry the client field, the
probe and async ready(), and then still throw on every request. The project
would ship a readiness endpoint that answers 503 forever, silently, with a
liveness endpoint that answers 200 beside it.

The check now proves the sentinel is gone rather than that a success string is
present — the same shape services/shared/flask.sh uses, since flask had the
identical hole and it was fixed there first. services/shared/laravel.sh and
services/mongodb/drivers/laravel.sh do not have it: routes/health.php ships
no liveness route, so their ['status' => 'ok'] check has nothing to match
except the splice.

Nothing else changes. The splice itself was never broken — this is its alarm.

How it was verified

The negative case first, because a guard is only worth what it catches. Against
a copy of the shipped controller with three of the four splices applied and the
throw deliberately left in place:

  • the old guard: passes — the missed splice goes unnoticed
  • the new guard: fails — die fires

Then the positive case, end to end on both provider branches, since the SQL and
mongodb drivers both source this body:

  • ./scripts/deploy-check.sh nestjs --db postgres
  • ./scripts/deploy-check.sh nestjs --db mongodb

Each generates a project, builds the image, starts the released stack and gets
200 from /health/live and /health/ready.

  • mise run lint and ./scaffold lint — clean
  • mise run test-runner — both lanes

Checklist

  • mise run lint passes
  • mise run test-runner passes
  • New behaviour has a test that fails without the change
  • Docs that describe changed behaviour were updated in the same commit
  • No unrelated changes

@ttncode
ttncode merged commit 8ad2131 into main Sep 13, 2026
21 checks passed
@ttncode
ttncode deleted the fix/nest-splice-guard branch September 13, 2026 19:00
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