Skip to content

fix(auth): recover from an unclaimable PR environment on dev signup - #304

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixauth-recover-from-unclaimable-pr-babcb6
Draft

posthog[bot] wants to merge 1 commit into
mainfrom
posthog-self-driving/fixauth-recover-from-unclaimable-pr-babcb6

Conversation

@posthog

@posthog posthog Bot commented Aug 29, 2026

Copy link
Copy Markdown

Problem

  • Internal testers on dev/QA get hard-blocked on the "Complete your Account" form when they type a PR number whose environment was never provisioned, with no way out.
  • A prNumber makes the backend skip the "claim any READY cluster" path and look only for a tenant-<prNumber>-* namespace. When it is missing or not READY, the form showed the raw backend string in a toast, never disabled submit, and stacked a fresh toast on each retry — so testers just hammered Start Free Trial.
  • Dev-only: the PR Number field renders only when NEXT_PUBLIC_PR_NUMBER_ENABLED is set, and PR-number registration runs only in the dev/QA auth-server configs. Production signup is untouched.

Changes

  • Route the two distinct backend failures to a persistent inline notice on the PR Number field, instead of a toast that fades:

    Backend code HTTP Notice
    PR_NAMESPACE_NOT_FOUND 404 PR environment #N is not provisioned.
    PR_NAMESPACE_UNAVAILABLE 409 PR environment #N is not ready.
  • Disable submit while the notice stands (via the existing isValid gate).

  • Offer recovery: a "Clear the PR number to use a shared dev cluster" action, and clearing/editing the field also clears the notice.

  • registerOrganization now returns the PR-namespace issue instead of toasting it; every other outcome is handled as before.

  • Reuses the inline-notice pattern from fix(auth): show registration-capacity block as a persistent inline notice with recovery #225 (the Input error/errorVariant slot) rather than adding a new banner.

Why

Testers hit this repeatedly on dev, each incident costing a full signup attempt plus triage time, with no in-UI hint that leaving the field blank is the workaround.

Testing

  • getPrNamespaceIssue unit test pins the code → issue mapping (missing vs not-ready, and pass-through for other codes).
  • tsc --noEmit and biome check clean on the changed files.

Note

A live dev reproduction (a real 404/409 from an unprovisioned PR environment) was not possible in the build sandbox — it needs the SaaS backend with pr-number-registration enabled. Reviewers should confirm the notice, disabled submit, and recovery on a dev host with NEXT_PUBLIC_PR_NUMBER_ENABLED=true.

Agent context

  • The report named flamingo-stack/openframe-saas-tenant, but that is a GitOps/config repo — signup-page.tsx and fix(auth): show registration-capacity block as a persistent inline notice with recovery #225 live here, so the fix lands here.
  • Considered a proactive pre-submit validation endpoint, but no such backend route exists and building one spans two repos; submit-time handling that then becomes persistent + recoverable delivers the same outcome with a frontend-only change.

Created with PostHog Desktop from this inbox report.

On dev/QA the signup form renders an optional PR Number field. A prNumber whose
tenant-<prNumber>-* namespace is missing (404 PR_NAMESPACE_NOT_FOUND) or not
READY (409 PR_NAMESPACE_UNAVAILABLE) failed with a fading toast that showed the
raw backend string, left submit enabled, and stacked a new toast per retry.

Route those two codes to a persistent inline notice on the PR Number field that
names the cause (missing vs not ready), disable submit while it stands, and offer
"clear the PR number to use a shared dev cluster" as recovery. Editing or
clearing the field clears the notice. Reuses the inline-notice pattern from
PR #225.

Dev/QA only: the field renders only when NEXT_PUBLIC_PR_NUMBER_ENABLED is set.

paths:
  src/app/(auth)/auth/constants/auth-error-codes.ts
  src/app/(auth)/auth/constants/auth-error-codes.test.ts
  src/app/(auth)/auth/hooks/use-auth.ts
  src/app/(auth)/auth/pages/signup-page.tsx

Generated-By: PostHog Desktop
Task-Id: 35ac829f-6788-4788-ac14-1ff944e9cdbf
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.

0 participants