Skip to content

fix(dogfood 2026-06-19): surface invalid CSRF origin error + guard test (ISSUE-001/003)#155

Merged
engels74 merged 1 commit into
mainfrom
fix/dogfood-findings-2026-06-19
Jun 19, 2026
Merged

fix(dogfood 2026-06-19): surface invalid CSRF origin error + guard test (ISSUE-001/003)#155
engels74 merged 1 commit into
mainfrom
fix/dogfood-findings-2026-06-19

Conversation

@engels74

Copy link
Copy Markdown
Owner

Summary

Resolves the three findings from the current dogfood run (ISSUE-001/002/003) per the consensus-approved plan .omc/plans/fix-dogfood-findings-2026-06-19.md (Option A, evidence-scoped). The guiding principle was to fix what the code actually does: of the three reported findings, only one was a live code defect, one was already fixed (stale logs), and one was not sourced in this app.

Changes

ISSUE-003 (Low) - invalid CSRF origin now surfaces an app-level error

Added the novalidate attribute to <form id="csrf-origin-form"> in src/routes/admin/settings/security/+page.svelte.

Previously, the type="url" input triggered native browser validation that silently blocked submit, so the server-side validation never fired and the user saw no feedback. With novalidate, an invalid origin reaches the ?/updateCsrfOrigin action, which returns fail(400, { fieldErrors: { csrfOrigin: ['Invalid URL format'] } }), and the existing csrfOriginError block renders the message inline.

This matches the established openai-settings-form idiom in connections/+page.svelte rather than downgrading the input to type="text". The type="url" semantics (keyboard/autofill), the use:enhance handler, and the server-side Zod .url() schema are all unchanged and remain authoritative. An inline comment documents why the attribute is present, to prevent a future regression.

ISSUE-001 (Low) - unauthenticated action TypeError (already fixed; test gap closed)

No production code change. The dogfood-logged TypeError: ...'locals.user.id' was stale (pre-ISSUE-006 build). A full locals.user dereference sweep confirms every user-facing surface self-guards before dereferencing the user: the wrapped [identifier] actions already return a clean fail(401) via their inline !locals.user guards.

To lock this in, this PR adds tests/unit/wrapped/identifier-actions-auth-guard.test.ts (mirroring the existing dashboard/settings-auth-guard.test.ts), which asserts that toggleLogo, updateShareMode, and regenerateToken:

  • return 401 (not a 500/TypeError) when locals.user is undefined, and
  • pass the guard for an authenticated user (invalid input yields 400, never 401).

The verified deref-sweep audit table is reproduced in the test-file header. Removing any guard now fails CI.

ISSUE-002 (Low) - Plex signin console warning (closed as environmental)

No code change. The clients.plex.tv/api/v2/users/signin 400 is not sourced in this application: there is no Plex web SDK in package.json/node_modules, and no users/signin or clients.plex.tv reference anywhere in src (the only Plex client call is plex-login.ts -> plex.tv/api/v2/pins). It is third-party browser/extension noise. No console-warning suppressor was added, since the app does not own this request.

Verification

  • bun run check - 0 errors, 0 warnings
  • bunx biome check (touched files) - clean
  • bun run test (full suite) - 2164 pass / 0 fail, exit 0 (80% line/function coverage thresholds held)
  • New test file - 6/6 pass

Notes

The documentation addendum for this run lives in dogfood-output/report.md, which is gitignored (local QA artifact), so it is not part of this diff. The committed deliverables are the form fix and the new regression test.

…st (ISSUE-001/003)

Resolve the current dogfood run's findings (ISSUE-001/002/003) per
.omc/plans/fix-dogfood-findings-2026-06-19.md (Option A, evidence-scoped).

ISSUE-003 (CSRF origin): add `novalidate` to the csrf-origin-form so an
invalid origin reaches the `?/updateCsrfOrigin` action and renders the
inline `csrfOriginError`, instead of the browser silently blocking submit
on the `type="url"` input. Matches the existing `openai-settings-form`
idiom (connections/+page.svelte). The input type, enhance handler, and the
server-side Zod `.url()` validation are unchanged and remain authoritative.

ISSUE-001 (unauth action TypeError): no production change required - the
inline `!locals.user` guards on the wrapped [identifier] actions already
return a clean 401; the dogfood-logged TypeErrors were stale (pre-ISSUE-006).
Add a regression test asserting toggleLogo, updateShareMode, and
regenerateToken return 401 (not 500) when unauthenticated, and 400-not-401
for an authenticated user, with the verified deref-sweep audit in the header.

ISSUE-002 (clients.plex.tv signin warning): closed as environmental - no
Plex web SDK or users/signin reference exists in the source; no suppressor
added.

Verification: bun run check (0 errors), biome check (clean),
bun run test (2164 pass / 0 fail, coverage thresholds held).
@augmentcode

augmentcode Bot commented Jun 19, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR addresses recent dogfood findings by making invalid CSRF-origin input failures visible to the user and by adding a regression test to prevent unauthenticated form actions from throwing.

Changes:

  • Adds novalidate to the CSRF origin settings form so browser-native URL validation doesn’t silently block submits and server-side validation errors can render inline.
  • Adds a new unit test covering wrapped [identifier] actions to ensure they return fail(401) when locals.user is missing (no TypeError/500 regressions).
  • Verifies authenticated requests pass the guard and reach subsequent validation (e.g., 400 for invalid params), not an incorrect 401.

Technical Notes: Keeps the type="url" input semantics while relying on server-side Zod validation as the source of truth for CSRF origin normalization/format checks.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@engels74
engels74 merged commit 4fb7543 into main Jun 19, 2026
3 checks passed
@engels74
engels74 deleted the fix/dogfood-findings-2026-06-19 branch June 19, 2026 10:51
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