Skip to content

Organizer actions build the ?error= refusal redirect by hand six times, and spell out a signup's revalidation path though revalidateSignup exists #1006

Open

Description

@richshaw

What happens

The organizer app's redirect-based server actions share a small contract: on a refusal, redirect to the page with ?error=<code> (a code only, never words), and the page reads it back through refusalFromQuery in src/lib/organizer-errors.ts. The read side is shared; the write side isn't. Under src/app/(organizer)/app/(chrome)/:

  • Six hand-built redirects: setOrganizerLocaleAction and switchOpenSignupsLocaleAction in settings/actions.ts, saveSignupSettingsAction and deleteSignupAction in signups/[id]/actions.ts, and two in the disconnect action of settings/connected-apps/page.tsx.
  • Revalidation spelled out twice: revalidateSignup in signups/[id]/actions.ts wraps revalidatePath(/app/signups/${id}, 'layout'), but deleteSignupAction (same file) and switchOpenSignupsLocaleAction (settings/actions.ts) write the call out again.
  • The Settings tab path is built twice in signups/[id]/actions.ts (saveSignupSettingsAction and deleteSignupAction).

Only developers notice. A new screen that copies one of these can put something other than a code in the query, or revalidate the wrong path.

Fix, in outline

  • refusalRedirect(path, code): never next to refusalFromQuery in src/lib/organizer-errors.ts, used at all six sites.
  • Move revalidateSignup to a plain server module (not a 'use server' file, which can only export actions) and use it from both actions files.
  • One settingsTab(id) path in signups/[id]/actions.ts, used by both actions.
  • Leave the page side alone: the three pages already share refusalFromQuery, and a wrapper would save about a line each.

Watch for

  • This saves almost no lines (each redirect is already one line); what it buys is one place for the ?error= rule and the revalidation path.
  • Tests pin the URLs (settings/actions.db.test.ts, signups/[id]/actions.db.test.ts), e.g. /app/settings?error=invalid_input. They must pass unchanged.
  • Connected apps' disconnect keeps its try/catch and internal fallback; only the redirect line changes. Open PR Say an app is already disconnected on Connected apps #885 changes the same action: whichever lands second has a small merge.
  • /login?error=… is Auth.js's error contract, not this one; leave it (and The sign-in redirect URL is built by hand in five places #816) alone.

Done when

  • No ?error= is built by hand in an organizer action; all go through refusalRedirect.
  • revalidatePath(/app/signups/appears once insrc`.
  • pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test && pnpm test:db pass.

Found by the pipeline's refactor scout in the organizer app's server actions, at 622ff81. Checked by an independent agent that listed every site and confirmed the db tests pin byte-identical URLs. https://claude.ai/code/session_016YZ9SV6Kn1Xiba7a7RGt7E

Held back by the scout: confirmed, but it's about line-neutral, so it's worth a PR only if one place for the rule is worth it to you. Add pipeline:ready to queue it.

Activity

  1. added
    enhancement
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions