Skip to content

fix(config): debug: true is unconditional, so production returns full SQL and stack traces on every error - #692

Merged
Ardnived merged 4 commits into
mainfrom
claude/fix-debug-production-disclosure
Sep 5, 2026
Merged

Ardnived merged 4 commits into
mainfrom
claude/fix-debug-production-disclosure

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Production stops answering errors with its own SQL. debug is now !isProduction; it was unconditionally true, and Payload gates its error redaction on exactly that flag.
  • A 22P02 still answers 400 naming the bad value — the disclosure decision recorded on the ticket. It needed no code change, and the reason is an ordering in Payload that nothing of ours stated until now.
  • Nothing stops being logged. debug is the response-body switch, not a logger setting.
  • A revert of that one line now turns a gate red. tests/e2e/error-disclosure.e2e.spec.ts reads 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 is NODE_ENV rather than isProductionDeployment().
  • tests/e2e/error-disclosure.e2e.spec.ts — new. The only gate that observes the shipped value: the Railway preview boots the real config at NODE_ENV=production.
  • tests/utils/restRequest.ts — new. Drives the real REST pipeline via handleEndpoints.
  • tests/utils/testHelpers.ts — the test config now takes debug and registers databaseErrorPlugin(), 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_TOKEN is not present in a routine session, so scripts/get-railway-preview-url.ts cannot 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., no stack, no SQL, no bound parameters
  • GET /api/meditations?where[type][equals]=path → still 400 with code: 22P02

Test results

  • Lean gate on 5a79e07: ✓ pnpm lint, ✓ pnpm typecheck, ✓ pnpm typecheck:tests, ✓ pnpm test:unit — 120 files / 1564 specs
  • Targeted integration on 5a79e07: error-disclosure + error-disclosure-debug, 9 cases green, against a local Postgres from scripts/ensure-test-db.sh
  • The new smoke spec, run for real — see the collapsible block below. Passes at debug: false, fails at debug: true
  • CI green on e943819 (the previous head): Lint, Test & Smoke — conclusion: success; pnpm test passed in 7m25s, Railway commit status success
  • Full integration lane on e943819: 71 files / 1163 specs, all green. Run in full rather than targeted because testHelpers.ts is the shared fixture every int suite consumes
  • No migration. No collection, field or global changed. The contract step (pnpm db:migrations:create --skip-empty) exited 124, which workflow.json says to hand off rather than retry — flagged below
  • Build: N/A — Railway builds on the preview deploy

Notes 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's onExit124 I 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.ts is reverted, because both pass their own debug to createTestEnvironment — 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_TOKEN and no PREVIEW_ADMIN_PASSWORD. So it was exercised against a throwaway harness that served an integration-lane Payload instance over real HTTP through handleEndpoints, with PREVIEW_URL pointed at it — the same transport Playwright uses in CI, one debug value apart.

debug served Result
false (production's value) 2 passed
true (exactly what reverting the config line ships) 1 failed, 1 passed. The redaction case reports + "stack": "Error: Failed query: select "id", "label", … limit $2 against the expected { errors: [{ message: 'Something went wrong.' }] }

The 400 case passes in both, which is correct rather than a weakness: databaseErrorPlugin is 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_URL rather than falling back to localhost:3000, which is a development server where debug is 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
Defect reintroduced What goes red
debug forced unconditionally true in createBaseTestConfig — the actual bug both production redaction cases: expected {…} to deeply equal {errors:[{message:'Something went wrong.'}]}, and expected '{"errors":[{"message":"Failed query: …' not to contain 'Failed query'. The development suite stays green — the asymmetry is the point
databaseErrorPlugin() removed from the test config all three 22P02 cases, across both files: expected 500 to be 400. And the body reads Something went wrong. — which is the ticket's "middle column is the worst of the three", reproduced
Development suite flipped to debug: false its two disclosure cases: expected '…Something went…' to contain 'Failed query'
mapPostgresCastError returns drizzle's wrapper instead of the driver's message all three 400 cases, including not to contain 'Failed query' — so the "the 400 leaks no SQL" assertion is load-bearing, not decorative

The one control assertion (the local API still throws the unredacted error) cannot be broken from production code, since redaction lives only in routeError. Verified reached rather than merely green by negating its regex: it fails with but 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 afterError hooks run inside payload/dist/utilities/routeError.js, and so does the config.debug redaction; payload.find() throws straight past both. That is why database-cast-errors.int.spec.ts asserts the mapper against a caught error and says so in its own docblock. handleEndpoints is Payload's public REST entry point — the same function @payloadcms/next's REST_GET calls, which is what src/app/(payload)/api/[...slug]/route.ts mounts — so this reaches into no dist/ internals.

No path override is passed to it. It is documented as "Override path from the request" and defaults to new 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. getPayload caches per config, so a second createTestEnvironment() in one file returns the first instance — a same-file pair would have asserted one debug value twice while claiming to compare two. 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. Written into tests/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 debug off the app's real config means importing @/payload.config, which pulls in the JSX email templates; under a production transform that dies with jsxDEV 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=99999999999999999999 against a real Postgres.

With debug: true — 500:

{"errors":[{"message":"Failed query: select \"id\", \"label\", \"locale\", \"narrator_id\",
 \"song_tag_id\", \"duration\", … from \"meditations\" … order by \"meditations\".\"created_at\"
 desc limit $2\nparams: en,100000000000000000000"}],"stack":"Error: Failed query: select …"}

With debug: false — 500:

{"errors":[{"message":"Something went wrong."}]}

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]'s routeError.js: the Something went wrong. swap and the response.stack assignment both happen before the afterError reduce, and a hook's result.response then replaces the body wholesale. So the plugin's 400 survives debug: 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 in docs/architecture.md.

Why NODE_ENV and not isProductionDeployment(). Email and storage detect production by Railway's environment name precisely because a preview also runs NODE_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 and docs/architecture.md now say so.

Security review ran (the diff touches src/payload.config.ts, a securityReview.triggerPattern path) 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

`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
@sydevs-bot
sydevs-bot requested a review from Ardnived September 4, 2026 12:33
@railway-app

railway-app Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-692 environment in sahajcloud

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Sep 4, 2026 at 5:11 pm UTC
1 service not affected by this PR
  • mailpit

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 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 ensureAdmin that already exists → tests/int/error-disclosure.int.spec.ts:32
  • consider — path: path.split('?')[0] re-derives handleEndpoints' own default (handleEndpoints.js:106) → tests/utils/restRequest.ts:60
  • consider — !isProduction here vs. the file's own "production is isProductionDeployment(), NOT NODE_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 databaseErrorPlugin disclosure 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 (the config.debug early return, and the status !== 500 branch that keeps every 4xx public), dist/utilities/routeError.js (logError at :38, swap at :52, response.stack at :54, root afterError at :73), dist/utilities/handleEndpoints.{d.ts,js} (the optional path override 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's password123 default, which createRestClient re-hardcodes — noted, not flagged).
  • Consumer sides followed for the error-body contract: SahajAtlasWeb src/config/api/mutate.ts + mutate.test.ts, WeMeditateWeb server/cms-client.ts, SahajAtlasWordpress includes/{seo,sitemap}.php. None parses 5xx message text.
  • Blast radius of the shared-fixture change: createBaseTestConfig's new debug = false default matches Payload's own (the key was previously absent and config.debug is 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_TOKEN in 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

Comment thread tests/int/error-disclosure.int.spec.ts Resolved
Comment thread tests/utils/restRequest.ts Resolved
Comment thread src/payload.config.ts Resolved
Comment thread src/payload.config.ts Resolved
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
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-692 September 4, 2026 14:14 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

All four review threads are answered and resolved, and the one that mattered is closed rather than argued away: a revert of debug: !isProduction now turns a gate red. Pushed as 5a79e07.

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 — tests/e2e/error-disclosure.e2e.spec.ts, Playwright against the Railway preview, which boots the real payload.config.ts at NODE_ENV=production. It issues the two requests #684's checklist described in prose, so they stop being a manual step.

It was watched failing before it was pushed. Served through handleEndpoints over real HTTP: at debug: false both cases pass; at debug: true — exactly what a revert ships — the redaction case reports the full statement and a stack against the expected Something went wrong.

The other three threads, and the one place I pushed back
  • path: path.split('?')[0] dropped from createRestClient. Re-derived against the installed copy: handleEndpoints.js:106 is const pathname = path ?? new URL(req.url).pathname. Both int suites green without it — which is the evidence routing still matches, since a pathname carrying the query string answers 404 rather than 500.
  • The NODE_ENV question answered in both places. Previews redacting is deliberate, and it is what makes the smoke spec possible at all — a preview in development mode would have nothing to assert. Said in the config comment and in docs/architecture.md.
  • The 14-line comment trimmed to the two facts a future editor would get wrong. Honest caveat: net 13 lines against 14, because the NODE_ENV answer went in. The win is that no line is now a second copy of the history.
  • Pushed back on dropping the debug-ON control. The review recommended deleting it once the smoke spec exists. It covers fix(config): debug: true is unconditional, so production returns full SQL and stack traces on every error #684's fourth acceptance criterion — development keeps the verbose body — and the smoke lane structurally cannot, since a preview only ever runs one value of the flag. Kept, with a smaller claim in its docblock.
Gates on `5a79e07`

✓ pnpm lint · ✓ pnpm typecheck · ✓ pnpm typecheck:tests · ✓ pnpm test:unit (120 files / 1564 specs) · ✓ error-disclosure + error-disclosure-debug (9 cases) against a local Postgres.

The smoke spec has never run against a real Railway preview — a routine session has no RAILWAY_API_TOKEN and no PREVIEW_ADMIN_PASSWORD — so what is proven is that its assertions discriminate on debug and that both paths produce a 500 and a 400 over HTTP. CI's smoke job is the first thing to execute it against preview data, and a red one there is mine to fix.

@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

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Correcting my own comment above: CI is green on 5a79e07, but the smoke lane did not run — so the new gate has still never executed. I said CI would be the first thing to execute it. It wasn't.

Lint, Test & Smoke → conclusion: success at 14:35:08Z (20m16s), and Railway's commit status on the same SHA is success. What the job log shows, though:

14:23:01Z  railway status: state=success desc="Success"
   …  (repeated every ~15s for twelve minutes)
14:34:48Z  railway status: state=success desc="Success"
14:35:03Z  No Railway preview URL found within timeout — skipping smoke.
##[warning] No Railway preview was discovered for this commit, so the Tier-3 smoke
           lane did not run. The job is still green — treat it as 'unit +
           integration passed', not 'smoke passed'.

So the deploy succeeded and discovery still could not resolve a preview URL. That warning is the one tests/AGENTS.md tells a reader to look for before trusting the check, and it is firing here.

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 debug (the harness run in the PR body), but nothing has yet run them against the deployed config, which is the entire reason it exists.

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 here

A routine session has no RAILWAY_API_TOKEN, so I cannot query the Railway API to see whether the preview environment has a public domain assigned or whether the lookup itself is failing. Anything past "the deploy succeeded and no URL was resolved" would be a guess, and a guess about CI infrastructure is not something to put in a PR body.

@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

Comment thread src/payload.config.ts Resolved
@Ardnived Ardnived removed the awaiting label Sep 4, 2026
…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
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-692 September 4, 2026 17:08 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Comment trimmed to four lines and the thread is resolved — fc5a1df. Nothing else changed, and debug: !isProduction is untouched.

Sixteen lines down to four. What survives is the two facts a future editor would get wrong and cannot read off the line: that debug is the response-body switch rather than a logger setting, and that NODE_ENV is deliberate against the isProductionDeployment() rule this same file states 150 lines below. Everything cut was already in docs/architecture.md § "What an error body discloses (issue #684)", which the comment now names by section rather than only linking.

Gate on fc5a1df: ✓ pnpm lint · ✓ pnpm typecheck · ✓ pnpm typecheck:tests · ✓ pnpm test:unit (120 files / 1564 specs). Comment-only, so there is no assertion to watch failing.

Still true from the previous round, so you don't have to re-read it
  • The smoke lane did not run on the last CI pass despite a green check and a successful Railway deploy — URL discovery timed out. Pushing this re-runs the job, so it may or may not resolve a preview this time; either way the green means "unit + integration" until the log says otherwise. Tracked by #661, which this is a second data point for.
  • The one judgement call left on this PR is unchanged and was settled on the ticket: the 22P02 still answers 400 naming the Postgres type and the caller's own value.

@Ardnived — back to you.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Decision needed: ADD_TO_PROJECT_PAT needs Issues + Pull requests write on SahajCloud, or this PR cannot be merged even once you approve it. Your review comment is addressed and Lint, Test & Smoke is green — the blocker is a second, non-CI check.

The state / state check run on fc5a1df failed, and it is the state-machine caller, not a test job. It died trying to add the awaiting label to this PR:

POST https://api.github.com/repos/sydevs/SahajCloud/issues/692/labels
→ 403 Resource not accessible by personal access token
   x-accepted-github-permissions: issues=write; pull_requests=write

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 HOLD · failing: state / state on the CI half, on top of the CHANGES_REQUESTED that your re-review clears.

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
  • Failing job: state / state, run 33898960435, event pull_request_target, head fc5a1df, 17:08:29→17:08:35Z. Log read via get_job_logs; the stack is setAwaiting → POST /issues/692/labels. Workflow file .github/workflows/workflow-state.yml, referencing sydevs/claude-workflow/.github/workflows/state-machine.yml@main (e939bb7).
  • A second state / state run on the same head succeeded (17:08:41→17:08:45Z) — that one wrote no label. Both remain on the head, and the failed one is what the gate sees.
  • Lint, Test & Smoke on fc5a1df: conclusion: success, 17:08:30→17:28:58Z. Railway commit status sahajcloud - SahajCloud: success.
  • Gate output, workflow/lib/merge-gate.mjs via merge-verdict.mjs on the gathered snapshot: {"verdict":"HOLD","reason":"no approving review (CHANGES_REQUESTED)","ci":{"green":false,"reason":"failing: state / state"},"unresolved":0}.
  • All 5 review threads read resolved (get_review_comments).

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

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

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.

fc5a1df carries two state / state runs — the 17:08:35Z failure, and a 17:08:45Z success from a second event that wrote no label. The success does not replace the failure. I re-ran this PR's snapshot through merge-verdict.mjs just now: still ci.green: false — failing: state / state.

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

@Ardnived Ardnived removed the awaiting label Sep 5, 2026
@Ardnived
Ardnived merged commit e121652 into main Sep 5, 2026
4 of 5 checks passed
@github-project-automation github-project-automation Bot moved this from Changes requested to Done in SYDevelopers Technical Roadmap Sep 5, 2026
Ardnived added a commit that referenced this pull request Sep 5, 2026
)

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]>
Ardnived pushed a commit that referenced this pull request Nov 5, 2026
…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

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-692 — fc5a1df7 Deployed Sep 4, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

fix(config): debug: true is unconditional, so production returns full SQL and stack traces on every error

3 participants