fix(api): return 401 (not 500) on unauthenticated cards-collection writes #10
No reviewers
Labels
No labels
agent-context-drift
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: rstillwell/deckhearth#10
Loading…
Reference in a new issue
No description provided.
Delete branch "brief/fix-auth-bypass/6-cards-null-guard"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Follow-up hotfix to PR #8 / commit 258e479 (fix-auth-bypass Brief 2). The Brief 2 reviewer flagged that
pages/api/collections/[identifier]/cards.jsPOST/PUT/DELETE branches dereferenceuser.userIdwithout a null guard. Previously masked by the synthetic admin (anonymous-write-as-admin was the security hole); now degrades to NPE → HTTP 500 instead of a clean HTTP 401.Security side was already fixed by Brief 2. This PR is the cosmetic 500 → 401 cleanup.
Files changed
pages/api/collections/[identifier]/cards.js(+12 / -0)Three identical
if (!user) return 401guards added, one at the top of each of the POST, PUT, and DELETE branches. GET branch untouched (already guarded via${user ? sql\...` : sql``}` ternary pattern for anonymous public-collection reads).Test plan
npm run buildexits 0npm run lintadds zero new errors tocards.js(pre-existing repo lint debt unchanged at 128 problems)git grep \"if (!user)\" cards.jsreturns 3 hits (was 0 pre-PR), one per write branchpages/api/collections/**re-audited:thumbnails.js,permissions.js,activity.jsall have early null checks;[identifier].jsuses optional chaining. No further hotfixes needed for that route group.curl -X POST https://<preview>/api/collections/<public-slug>/cards -d '{\"cardId\":1}' -H \"Content-Type: application/json\"(no Authorization header) returns 401. Same for PUT and DELETE.Notes
\"Authentication required to modify this collection\"(distinct from generic\"Authentication required\"elsewhere) to match the user-visible 403 messaging just below in the same handler.withAuth(handler)wrapper introduced — that's a future refactor convoy. Minimal-invasive fix only.Convoy context
This closes the last open thread from
fix-auth-bypass. After this merges, the convoy's only remaining work is Brief 5 (vitest + auth tests, in flight as PR-pending) and the doc-writer pass.🤖 Pipeline metadata: convoy=fix-auth-bypass, brief=6 (post-architect hotfix), depends_on=[2 merged], audit=reviewer-only
Made with Cursor
The latest updates on your projects. Learn more about Vercel for GitHub.
Pipeline Health
Build + CI gates
Build runs on Vercel; this CI runs lint and schema-map drift only (no duplicate build).
Role reports
See individual comments above for details. This rollup updates automatically.