Repository navigation
fix(config): debug: true is unconditional, so production returns full SQL and stack traces on every error - #692
Conversation
`debug: true` was unconditional in `payload.config.ts` — not `!isProduction`.
The `!isProduction` twelve lines from the Sentry plugin is that plugin's own
`debug` option, a different key, which is what made this easy to read past.
Payload gates its production redaction on exactly that flag.
`isErrorPublic` returns true the moment `config.debug` is set, so `routeError`
never swaps a non-public error's body for `Something went wrong.`, and it also
attaches `response.stack`. So every unhandled error on cloud.sydevelopers.com
answered with its real message plus a stack trace — and for a database error
that message is drizzle's wrapper, carrying the full statement and every bound
value.
Measured rather than inferred. With the flag on, `GET /api/meditations?limit=
99999999999999999999` returns 500 with:
Failed query: select "id", "label", "locale", "narrator_id", … from
"meditations" … params: en,100000000000000000000
plus a `stack` key. With it off, the same request returns
`{"errors":[{"message":"Something went wrong."}]}` and nothing else.
The comment on the line said the intent was diagnostics. That intent is served
by `logger`, which is separate and unaffected: `routeError` calls `logError` at
ERROR with the full error before any of this, so nothing stops being logged and
nothing stops reaching Sentry.
`databaseErrorPlugin` needed no change and gets none. Its `afterError` hook runs
AFTER the redaction and replaces the body wholesale, so a 22P02 still answers 400
naming the Postgres type and the caller's own value — which is the disclosure
decision recorded on the ticket, and now the only path returning Postgres text.
Tests drive the REAL REST pipeline, because none of this is observable any other
way: `afterError` hooks run inside `routeError`, which the local API every other
integration spec uses throws straight past. `tests/utils/restRequest.ts` goes in
through `handleEndpoints` — Payload's own public REST entry point, the same one
`@payloadcms/next`'s `REST_GET` calls — with an authenticated caller, since
access control refuses an anonymous read with 403 before any query runs.
Two spec files rather than two `describe`s: `getPayload` caches per config, so a
second `createTestEnvironment()` in one file silently returns the first instance.
Observed while writing this — the second call fails creating its admin with
`The following field is invalid: email`, because it lands in the first suite's
schema.
`createBaseTestConfig` now takes `debug` (defaulting to false, which is what it
effectively was — the key was absent) and registers `databaseErrorPlugin()`,
which was missing from the test config entirely. Without that the new suites
would have asserted a pipeline the app does not run.
Closes #684
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015jfCmNa2u5GJiWH9vFmi3k
`docs/architecture.md`'s #670 section explained the 22P02 → 400 mapping but predated the `debug` fix, so it did not say that the plugin's 400 is now the ONLY path returning Postgres text — nor that it survives by ORDERING rather than by exemption. `routeError` redacts before it runs `afterError` hooks, and a hook's `result.response` replaces the body wholesale; a Payload release that moved root hooks above the swap would silently turn every cast failure back into an opaque 500. That is the fact a future reader needs and could not derive from our source. `tests/AGENTS.md` gains the REST harness: when to reach for `createRestClient` (only for behaviour that lives in the REST layer — the local API is faster and right for everything else), and the concrete shape of the one-environment-per-file rule, which the file already stated but without saying what violating it looks like. It looks like the second suite failing to create its admin. `tests/COVERAGE.md` gains the row for the two new suites, per its own instruction to update it when custom behaviour gains cover. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015jfCmNa2u5GJiWH9vFmi3k
|
🚅 Deployed to the SahajCloud-pr-692 environment in sahajcloud
1 service not affected by this PR
|
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The one-line fix is exactly right, and the 400 lines around it are where the questions are. debug: !isProduction is the whole ticket, it moves in the tightening direction, and the reading of isErrorPublic → routeError that justifies it holds — I re-read both in [email protected] and the ordering claim is correct (the Something went wrong. swap and response.stack are at routeError.js:52 and :54; the root afterError reduce is at :73), so databaseErrorPlugin's 400 does survive by ordering exactly as claimed.
The scope question is the test apparatus, not the fix. ~330 of the 407 added lines are fixture and specs that, by the PR body's own admission, stay green if payload.config.ts is reverted. The lane that would catch that revert already exists and already runs on every PR — tests/e2e/*.e2e.spec.ts against a Railway preview at NODE_ENV=production, with the auth helper the int specs had to rebuild. That is the strongest finding here: the PR's "Manual verification" section is a smoke spec someone wrote in prose instead of in the lane that runs it.
Contracts are clean. The change alters what a 5xx body says, and no consumer reads it: SahajAtlasWeb's refusalFrom (src/config/api/mutate.ts) branches on errors[].code for 4xx refusals only and already models a 500 as { message: 'Something went wrong.' } in its own specs; WeMeditateWeb's cms-client.ts lets server errors propagate to withCache's retry without reading the body; the WordPress plugin's SEO/sitemap paths are status-gated. Payload keeps every 4xx public regardless of debug (isErrorPublic returns true for any status ≠ 500), so no refusal envelope changes shape. Adding databaseErrorPlugin() to the shared test config is a genuine fixture-parity fix and I'd keep it whatever happens to the rest.
One consequence the ticket doesn't name: debug is not caller-scoped, so a logged-in admin hitting a 500 in the production admin panel now also gets Something went wrong. Scoping it would mean fighting Payload, so accepting it is right — but it is a real cost, and neither the ticket nor docs/architecture.md says it out loud.
Findings
- should-fix — the int pair cannot fail on a revert of the fix it exists for; the smoke lane can, with
ensureAdminthat already exists →tests/int/error-disclosure.int.spec.ts:32 - consider —
path: path.split('?')[0]re-deriveshandleEndpoints' own default (handleEndpoints.js:106) →tests/utils/restRequest.ts:60 - consider —
!isProductionhere vs. the file's own "production isisProductionDeployment(), NOTNODE_ENV" rule 156 lines below; previews now redact and nothing says so →src/payload.config.ts:68 - consider — 14-line comment on a one-token flag, most of it the removed system, duplicated in
docs/architecture.md→src/payload.config.ts:54-67
What was checked
- Ticket #684 read in full, including the recorded
databaseErrorPlugindisclosure decision. The diff is measured against its six acceptance criteria: criteria 1, 4 and 6 are addressed; 2 and 3 are preview-verification items the PR correctly leaves to the checklist; 5 was already closed on the ticket. - Upstream, re-derived rather than taken from the PR body —
[email protected]:dist/utilities/isErrorPublic.js(theconfig.debugearly return, and thestatus !== 500branch that keeps every 4xx public),dist/utilities/routeError.js(logErrorat :38, swap at :52,response.stackat :54, rootafterErrorat :73),dist/utilities/handleEndpoints.{d.ts,js}(the optionalpathoverride at :106). - Whole files read, not just the hunks:
src/payload.config.ts,src/plugins/databaseErrors/databaseErrorPlugin.ts,tests/utils/testHelpers.ts,tests/utils/restRequest.ts, both new specs,playwright.config.ts,tests/e2e/{auth,cors-preflight,images}.e2e.spec.ts,tests/utils/testData.ts(createManager'spassword123default, whichcreateRestClientre-hardcodes — noted, not flagged). - Consumer sides followed for the error-body contract: SahajAtlasWeb
src/config/api/mutate.ts+mutate.test.ts, WeMeditateWebserver/cms-client.ts, SahajAtlasWordpressincludes/{seo,sitemap}.php. None parses 5xx message text. - Blast radius of the shared-fixture change:
createBaseTestConfig's newdebug = falsedefault matches Payload's own (the key was previously absent andconfig.debugis undefined-by-default), so existing suites see no change from the flag;databaseErrorPlugin()does change what all 71 int files get for a 22P02, which is why the full-lane run reported in the PR body is the right evidence and I did not re-run it. - Not checked, deliberately: the preview requests themselves — no
RAILWAY_API_TOKENin this session, same limitation the PR reports. Both remain open verification-checklist items.
Advisory only — approval is @Ardnived's.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The int pair added in 660f8d2 cannot fail on a revert of the one-token fix it exists for: both suites pass their own `debug` to `createTestEnvironment`, so both stay green with `payload.config.ts` back at `debug: true`. The lane that CAN observe the shipped value already runs on every PR — Playwright against the Railway preview, which boots the real config at NODE_ENV=production — and already carries the login helper the int fixture had to rebuild. `tests/e2e/error-disclosure.e2e.spec.ts` asserts the two cases #684's "Manual verification" section described in prose: a 500 redacted to `Something went wrong.` with no SQL, bound parameters or stack, and `databaseErrorPlugin`'s 400 surviving that redaction. Watched failing at the site that causes it — served through `handleEndpoints` over real HTTP at `debug: true`, the redaction case reports the full statement plus a stack; at `debug: false` both cases pass. It skips without `PREVIEW_URL` rather than running against the localhost fallback, which is a development server where `debug` is on by design and the assertion would be correct and inapplicable at the same time. Also from the same review round: - Drop `path: path.split('?')[0]` from `createRestClient`. `handleEndpoints` documents `path` as an override and defaults it to `new URL(req.url).pathname` (handleEndpoints.js:106), which already excludes the query string. Both int suites stay green without it, which is what proves routing still matches. - Trim the 14-line comment on `debug` to the two facts a future editor would get wrong, and answer the question it left open: this is deliberately `NODE_ENV`, not the `isProductionDeployment()` rule stated 156 lines below for email and storage, so Railway PR previews redact too. That is also what makes the new smoke spec possible at all, and it is now recorded in docs/architecture.md. The debug-ON control is kept rather than dropped: it covers #684's fourth acceptance criterion — development keeps the verbose body — and the smoke lane cannot, since a preview only ever runs one value of the flag. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01P1BYtAUjyF22W3EGUXVk7p
|
All four review threads are answered and resolved, and the one that mattered is closed rather than argued away: a revert of The review's strongest finding was that this PR's own 330 lines of new fixture could not fail on a revert of the one-token fix they exist for. That is fixed by using the lane that already observes the deployment — It was watched failing before it was pushed. Served through The other three threads, and the one place I pushed back
Gates on `5a79e07`✓ The smoke spec has never run against a real Railway preview — a routine session has no @Ardnived — back to you. Nothing here needs a decision from you that the previous round did not; the 400's disclosure is still the one judgement call, and it is unchanged. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
Correcting my own comment above: CI is green on
So the deploy succeeded and discovery still could not resolve a preview URL. That warning is the one What this does and does not change. The two int suites and the whole unit lane really did pass on this SHA — that part of the green is real. What is unverified is the new smoke spec against preview data: its assertions are proven to discriminate on I am not filing a ticket for the discovery failure: #661 — smoke lane skips silently and asserts almost nothing is already open and is this exact class. This is a second, sharper data point for it — a successful deploy whose URL discovery still times out, which is not the "no preview environment" case that ticket was written around. Worth noting there when it is picked up. Why I am not chasing the cause hereA routine session has no @Ardnived — this does not need action from you before review; the diff is what it is either way. It does mean the green check on this PR is worth reading as "unit + integration", and the smoke assertion is still owed. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
…tself @Ardnived on #692: the comment is excessively long and verbose. Sixteen lines down to four. What survives is only what a future editor would get wrong and cannot read off `debug: !isProduction`: - it is the response-body switch, not a logger setting — the mistake that let the bug live; - `NODE_ENV` is deliberate against the `isProductionDeployment()` rule stated later in the same file, so previews redact too. Everything cut is stated at length in `docs/architecture.md` § "What an error body discloses (issue #684)", which the comment now points at by section name: the `routeError` ordering that keeps `databaseErrorPlugin`'s 400 alive, which specs pin which half, and why debugging a red preview means Railway's logs. A second copy in the hot config file is a copy that can drift. Comment-only. No behaviour change, and `debug: !isProduction` is untouched. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RmKmHiG2xuyL6FPCKcXq2j
|
Comment trimmed to four lines and the thread is resolved — Sixteen lines down to four. What survives is the two facts a future editor would get wrong and cannot read off the line: that Gate on Still true from the previous round, so you don't have to re-read it
@Ardnived — back to you. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
Decision needed: The The merge gate reads every check run on the head, so a red one holds the merge regardless of approval — I ran this PR's snapshot through it just now and it returns I have not worked around it. The fix is a credential I cannot touch: widen that PAT's repository access to SahajCloud with Issues and Pull requests write (the token itself is valid until 2026-10-03, so this is scope, not expiry). The next event after that re-runs the workflow green. Two consequences while it stands, both worth knowing:
Evidence
No fix attempt was made and no iteration of the CI fix cap was spent: the failure is a credential, and the routine's own rules forbid improvising around one. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
Correcting the plan above: widening the PAT will not clear this PR on its own. A failed check run stays on its commit forever, and the gate reads every one of them.
So once the PAT is widened, this PR needs a new head commit before the red clears. Any real push does it — check runs are per-commit, and the state-machine event on the new head then succeeds. Approving without that leaves it held. The alternative is a gate change — take the latest run per check name, as GitHub's required checks do. I have not made it. It loosens the one script that decides merges, the two runs here are concurrent rather than a retry so "latest" picks an arbitrary winner, and here it would turn a real 403 green. That is a decision, not a cleanup. Say the word and I will file it. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
) Rewrites every in-scope prose file (67 of 69 flagged by the audit) into strict Simplified Technical English and retires D1/Cloudflare Workers-era debris three months after the Postgres/Railway migration. Tracked *.md (excluding CLAUDE.md symlinks and the vendored .agents/skills/payload/ skill, left untouched pending ownership confirmation) drops from 770,090 to 600,797 chars (22%). The five hot-path files auto-imported every session (AGENTS.md, docs/architecture.md, docs/environment.md, docs/code-style.md, .claude/workflow.json) drop from 84,492 to 36,397 chars (57%). Deleted (dead, zero referrers, grepped clean): seed-issues-report.md, src/migrations/README.md (its one fact folded into src/migrations/AGENTS.md). Merged: DEPLOYMENT.md + RAILWAY_RUNBOOK.md split by lifecycle (how it runs today vs. provision-from-scratch/disaster-recovery), resolving their D1-decommission contradiction — PR #468 (merged 2026-06-08) confirms the Worker is gone, so the stale "Remaining (gated)" TODOs are removed, not reworded. Legacy debris fixed (D1/SQLite/Cloudflare-Workers-as-current retired): migration-reviewer.md's whole persona rewritten for Postgres/Drizzle, seeds/wemeditate/AGENTS.md's Dual-Database table corrected to Postgres, src/globals/AGENTS.md's json_array() rationale corrected to Postgres's real FUNC_MAX_ARGS=100 limit, docs/mcp-setup.md's cloudflare-docs row drops Workers/D1. grep for D1|SQLite|Cloudflare Workers across .claude/agents/, seeds/wemeditate/, src/globals/, docs/mcp-setup.md is clean. README.md's stale `cd sy-devs-cms` corrected to `cd SahajCloud`. Mandatory AGENTS.md fixes applied: dropped the nonexistent `pnpm test:e2e`, replaced the broken dev-server.sh path with the `/workflow:dev-server` skill, fixed the seeds/atlas/MIGRATION_PLAN.md:103 anchor (now resolves to `AGENTS.md#website-selection-rules-584`), collapsed duplicate PR-workflow/test-tier prose into single pointers to testing-reqs.md and the finalize-pr skill. Traps preserved (compressed, never deleted): the conflicted-PR "zero CI" diagnostic with its docs/why.md anchor and #632/#653 numbers; the Cache Rule authorization-header predicate and root-endpoint fix; DB_QUERY_LOGGING and TURNSTILE_SECRET_KEY footguns; storage.md's preview/prod asset-isolation risk; the payload-cli silent-exit/hang ladder; the migration snapshot out-of-order duplicate-re-emission trap; access.md's per-locale-roles gotcha (#665); endpoints.md's root-endpoint hook gap; email.md's two- token-URL-shapes bug; seeds/atlas/AGENTS.md's silent-rollback-on-trashed- relation trap; the never-name-a-global-field-locales rule. The 2026-08-27 dated Admin Access exception is kept (still current). Comment sweep: rewrote comments to STE in every file the audit flagged as touched (route.ts's mandatory dead-comment deletions, r2NativeAdapter.ts, Icon.tsx, scalarPlugin.ts, env/server.ts, localizedRolesAuth.ts, plus the full tests/seeds/scripts/.claude/root-config/.github sweep — 227 files total). Verified comment-only: every changed line in every .ts/.tsx/.mjs/ .cjs/.sh/.py file has an identical code portion before its comment marker; zero functional changes. Deleted a dead `sharp` import and several doc- duplicating/obvious comments (e.g. vitest.setup.ts's two narrate-the- obvious lines). Verification run as finisher: pnpm lint, typecheck, typecheck:tests, and the full unit lane (1564 tests) all pass, plus targeted integration specs for every touched collection/access path (events, regions, role-based- access — 79 tests, live Postgres). ste-lint.py run on all 40 changed .md files: hard violations cut from 169 to 118, concentrated in five already- dense reference docs (admin-ui/api-clients/email/endpoints/openapi/ storage.md) where the prior compression pass already prioritized fidelity over the linter's raw sentence-length cap; remaining flags are verified domain terms (Railway's "Health Check", Zod's "Validate", literal HTTP methods GET/DELETE, SQL "cascade delete", TS "type erasure") or residue in those five files. rule-delta.mjs vs main on AGENTS.md/docs/rules/*.md/ migration-reviewer.md: 3 directives flagged REMOVED, all three verified as de-bolded (not deleted) — "GET /api/events/geojson always excluded, no opt-out" (api-clients.md) and the two CPU parallel-test-run rules (testing-reqs.md) all still present as plain bullets/cells, content identical. 1 flagged ADDED is the same pass-by-reference comment rule gaining full-sentence bold (previously invisible to the tool since only "Do not" was bold). Sequencing: PRs #692 (UNKNOWN), #686 (BLOCKED, not CONFLICTING), #691 (CLEAN) show no current CONFLICTING/DIRTY state, so this PR is not blocked today, though #692/#691 touch overlapping files and should land or be watched. securityReview trigger paths (access/, storage/, api routes, webhook scripts) all confirmed comment-only. Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…tself @Ardnived on #692: the comment is excessively long and verbose. Sixteen lines down to four. What survives is only what a future editor would get wrong and cannot read off `debug: !isProduction`: - it is the response-body switch, not a logger setting — the mistake that let the bug live; - `NODE_ENV` is deliberate against the `isProductionDeployment()` rule stated later in the same file, so previews redact too. Everything cut is stated at length in `docs/architecture.md` § "What an error body discloses (issue #684)", which the comment now points at by section name: the `routeError` ordering that keeps `databaseErrorPlugin`'s 400 alive, which specs pin which half, and why debugging a red preview means Railway's logs. A second copy in the hot config file is a copy that can drift. Comment-only. No behaviour change, and `debug: !isProduction` is untouched. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RmKmHiG2xuyL6FPCKcXq2j
Summary
debugis now!isProduction; it was unconditionallytrue, and Payload gates its error redaction on exactly that flag.debugis the response-body switch, not a logger setting.tests/e2e/error-disclosure.e2e.spec.tsreads the flag off the deployed preview rather than a fixture — added in the review round, and the thing this PR's first draft could not do.Changes
src/payload.config.ts— the flag, and a comment saying what it controls and why it isNODE_ENVrather thanisProductionDeployment().tests/e2e/error-disclosure.e2e.spec.ts— new. The only gate that observes the shipped value: the Railway preview boots the real config atNODE_ENV=production.tests/utils/restRequest.ts— new. Drives the real REST pipeline viahandleEndpoints.tests/utils/testHelpers.ts— the test config now takesdebugand registersdatabaseErrorPlugin(), which was missing from it entirely.tests/int/error-disclosure{,-debug}.int.spec.ts— production and development, one flag apart. These own the pipeline; the smoke spec owns the setting.Preview
Railway deployed the per-PR environment (SahajCloud-pr-692) — deploy status
success, and CI's smoke lane ran against it.I could not print the public preview host here:
RAILWAY_API_TOKENis not present in a routine session, soscripts/get-railway-preview-url.tscannot run. The host is in the Railway comment above.The two requests from the ticket's checklist are no longer a manual step — the smoke spec issues them on every CI run:
GET /api/meditations?limit=99999999999999999999→Something went wrong., nostack, no SQL, no bound parametersGET /api/meditations?where[type][equals]=path→ still 400 withcode: 22P02Test results
5a79e07: ✓pnpm lint, ✓pnpm typecheck, ✓pnpm typecheck:tests, ✓pnpm test:unit— 120 files / 1564 specs5a79e07:error-disclosure+error-disclosure-debug, 9 cases green, against a local Postgres fromscripts/ensure-test-db.shdebug: false, fails atdebug: truee943819(the previous head):Lint, Test & Smoke—conclusion: success;pnpm testpassed in 7m25s, Railway commit statussuccesse943819: 71 files / 1163 specs, all green. Run in full rather than targeted becausetestHelpers.tsis the shared fixture every int suite consumespnpm db:migrations:create --skip-empty) exited 124, whichworkflow.jsonsays to hand off rather than retry — flagged belowNotes for reviewer
The one thing worth your judgement is what the 400 still discloses, and it is unchanged by this PR — a Postgres type name plus the caller's own value. That was decided on the ticket; I have not reopened it. What changed is that it is now the only path returning Postgres text, which is why the docs say so.
The contract step exited 124 rather than confirming "no migration needed". The diff touches no collection, field or global, so none is expected — but I could not demonstrate that, and per
workflow.json'sonExit124I did not retry.The gap this PR opened with is closed, and the correction is worth reading. The first draft said plainly that neither int suite fails if
payload.config.tsis reverted, because both pass their owndebugtocreateTestEnvironment— true, and the strongest finding of the review round. The answer was not to make the int lane cleverer but to use the lane that already observes the deployment. What is still true is the narrower claim: the int pair pins the pipeline (what each value discloses, and that the plugin's 400 survives both), which is the half that belongs to Payload and can change under us.The new smoke spec, watched failing at the site that causes it
The spec has never run against a real Railway preview — a routine session has no
RAILWAY_API_TOKENand noPREVIEW_ADMIN_PASSWORD. So it was exercised against a throwaway harness that served an integration-lane Payload instance over real HTTP throughhandleEndpoints, withPREVIEW_URLpointed at it — the same transport Playwright uses in CI, onedebugvalue apart.debugservedfalse(production's value)true(exactly what reverting the config line ships)+ "stack": "Error: Failed query: select "id", "label", … limit $2against the expected{ errors: [{ message: 'Something went wrong.' }] }The 400 case passes in both, which is correct rather than a weakness:
databaseErrorPluginis independent of the flag in both directions, so that case is a survival check, not a discriminator. Naming it here so the next reader does not mistake a green for coverage it is not.What is still unmeasured: whether the preview's cloned-prod data reaches the same two failures. CI's smoke job is the first thing to execute that.
It skips without
PREVIEW_URLrather than falling back tolocalhost:3000, which is a development server wheredebugis on by design — a redaction assertion there would be correct and inapplicable at once. On a preview both cases are unconditional; a skip there would make the check vacuous.Every new assertion in the original commit was watched FAILING — four experiments, each at the site that would really cause it
debugforced unconditionally true increateBaseTestConfig— the actual bugexpected {…} to deeply equal {errors:[{message:'Something went wrong.'}]}, andexpected '{"errors":[{"message":"Failed query: …' not to contain 'Failed query'. The development suite stays green — the asymmetry is the pointdatabaseErrorPlugin()removed from the test configexpected 500 to be 400. And the body readsSomething went wrong.— which is the ticket's "middle column is the worst of the three", reproduceddebug: falseexpected '…Something went…' to contain 'Failed query'mapPostgresCastErrorreturns drizzle's wrapper instead of the driver's messagenot to contain 'Failed query'— so the "the 400 leaks no SQL" assertion is load-bearing, not decorativeThe one control assertion (
the local API still throws the unredacted error) cannot be broken from production code, since redaction lives only inrouteError. Verified reached rather than merely green by negating its regex: it fails withbut got 'Failed query: select count(*) from "t…'.Why the tests go through `handleEndpoints`, and why two files
None of this is observable from the local API. Root
afterErrorhooks run insidepayload/dist/utilities/routeError.js, and so does theconfig.debugredaction;payload.find()throws straight past both. That is whydatabase-cast-errors.int.spec.tsasserts the mapper against a caught error and says so in its own docblock.handleEndpointsis Payload's public REST entry point — the same function@payloadcms/next'sREST_GETcalls, which is whatsrc/app/(payload)/api/[...slug]/route.tsmounts — so this reaches into nodist/internals.No
pathoverride is passed to it. It is documented as "Override path from the request" and defaults tonew URL(req.url).pathname(handleEndpoints.js:106), which already excludes the query string; the first draft re-derived that default by hand. Removed in the review round, and the int suites staying green is the evidence routing still matches — a pathname carrying the query string would answer 404, not 500.The requests are authenticated, and that is not incidental. Access control refuses an anonymous read with 403 before any query runs, so an unauthenticated request never reaches Postgres and cannot produce a database error at all. The first draft asserted 400 and got 403.
Two spec files rather than two
describes.getPayloadcaches per config, so a secondcreateTestEnvironment()in one file returns the first instance — a same-file pair would have asserted onedebugvalue twice while claiming to compare two. Observed while writing this: the second call fails creating its admin withThe following field is invalid: email, because it lands in the first suite's schema. Written intotests/AGENTS.md, which stated the rule but not what breaking it looks like.The debug-ON control is kept deliberately. It covers #684's fourth acceptance criterion — local dev and E2E keep the verbose bodies — and the smoke lane structurally cannot, since a preview only ever runs one value of the flag.
Why not assert the config line from the int lane. Reading
debugoff the app's real config means importing@/payload.config, which pulls in the JSX email templates; under a production transform that dies withjsxDEV is not a function. A fragile guard around a one-token constant is worse than none — the smoke spec observes the value instead of importing it.The disclosure, measured rather than inferred
GET /api/meditations?limit=99999999999999999999against a real Postgres.With
debug: true— 500:With
debug: false— 500:The cast failure, in both: 400,
{"errors":[{"code":"22P02","message":"Invalid value in request: invalid input value for enum enum_meditations_type: \"path\""}]}.Why the plugin was unaffected, read in
[email protected]'srouteError.js: theSomething went wrong.swap and theresponse.stackassignment both happen before theafterErrorreduce, and a hook'sresult.responsethen replaces the body wholesale. So the plugin's 400 survivesdebug: false— and a release that moved root hooks above the swap would silently turn every cast failure back into an opaque 500. That is what the int suite pins, and it is now indocs/architecture.md.Why
NODE_ENVand notisProductionDeployment(). Email and storage detect production by Railway's environment name precisely because a preview also runsNODE_ENV=production. This flag wants the opposite answer: a preview is as publicly reachable as production, so it redacts too. The cost is that debugging a red preview means Railway's logs rather than the response body; the benefit is that the smoke spec above can exist at all. Both the config comment anddocs/architecture.mdnow say so.Security review ran (the diff touches
src/payload.config.ts, asecurityReview.triggerPatternpath) and found nothing: one production line, moving in the tightening direction.Closes #684
🤖 Written by the sydevs autonomous loop — see what this is
🤖 Generated with Claude Code
https://claude.ai/code/session_01P1BYtAUjyF22W3EGUXVk7p