|
| 1 | +# PR_26166_163-create-account-live-diagnostic-fix |
| 2 | + |
| 3 | +## Branch Validation |
| 4 | + |
| 5 | +- Current branch: `main` |
| 6 | +- Expected branch: `main` |
| 7 | +- Result: PASS |
| 8 | + |
| 9 | +## Summary |
| 10 | + |
| 11 | +Added safe local API operator diagnostics for `POST /api/auth/create-account` and preserved the live Create Account runtime path. Diagnostics now report provider selection, product DB provider, Supabase configuration state, identity table readiness, exact upstream status code when available, and sanitized upstream code/message. |
| 12 | + |
| 13 | +No secrets are printed. Browser responses remain production-safe. |
| 14 | + |
| 15 | +## Runtime Diagnostic Evidence |
| 16 | + |
| 17 | +Captured from the running `npm run dev:local-api` local API console under `docs_build/dev/reports/PR_26166_163-local-api-console-errors.txt`. |
| 18 | + |
| 19 | +Successful Create Account: |
| 20 | + |
| 21 | +```text |
| 22 | +[auth/operator] POST /api/auth/create-account diagnostic phase=start selectedAuthProvider=supabase-auth dbProvider=local-db supabaseConfigured=yes identityTablesReady=yes upstreamStatusCode=none safeErrorCode=none safeMessage=ready-check-complete |
| 23 | +[auth/operator] POST /api/auth/create-account diagnostic phase=success selectedAuthProvider=supabase-auth dbProvider=local-db supabaseConfigured=yes identityTablesReady=yes upstreamStatusCode=200 safeErrorCode=none safeMessage=account-created-and-identity-provisioned |
| 24 | +``` |
| 25 | + |
| 26 | +Repeated-email manual failure diagnostic: |
| 27 | + |
| 28 | +```text |
| 29 | +[auth/operator] POST /api/auth/create-account diagnostic phase=upstream-failed selectedAuthProvider=supabase-auth dbProvider=local-db supabaseConfigured=yes identityTablesReady=yes upstreamStatusCode=422 safeErrorCode=422 safeMessage=A user with this email address has already been registered |
| 30 | +[auth/operator] POST /api/auth/create-account failed: Create account: Supabase Auth request failed with HTTP 422. |
| 31 | +``` |
| 32 | + |
| 33 | +The browser-facing repeated-email response stayed production-safe: |
| 34 | + |
| 35 | +```text |
| 36 | +The site is currently unavailable. Please try again later. |
| 37 | +``` |
| 38 | + |
| 39 | +## Manual Browser Validation |
| 40 | + |
| 41 | +Used the real browser page at `http://127.0.0.1:5501/account/create-account.html` against the running local API. |
| 42 | + |
| 43 | +Validation flow: |
| 44 | + |
| 45 | +- Created a fresh account successfully. |
| 46 | +- Submitted the same email again to trigger the current repeated-email upstream failure and captured the local API diagnostic. |
| 47 | +- Submitted a second fresh account successfully. |
| 48 | +- Signed in through `http://127.0.0.1:5501/account/sign-in.html`. |
| 49 | +- Verified `/api/session/current` authenticated as the newly created user with the `user` role. |
| 50 | + |
| 51 | +Final successful result: |
| 52 | + |
| 53 | +```text |
| 54 | +Create Account HTTP: 200 |
| 55 | +Create Account UI status: Account created. You can sign in after confirming your email. |
| 56 | +identityProvisioned: true |
| 57 | +users row created: true |
| 58 | +user_roles row created: true |
| 59 | +roleSlugs: user |
| 60 | +Sign In HTTP: 200 |
| 61 | +sessionAuthenticated: true |
| 62 | +sessionUserKeyMatchesFinalCreate: true |
| 63 | +sessionRoles: user |
| 64 | +failedRequests: none |
| 65 | +``` |
| 66 | + |
| 67 | +## Requirement Checklist |
| 68 | + |
| 69 | +- Main branch only: PASS |
| 70 | +- Read `docs_build/dev/PROJECT_INSTRUCTIONS.md`: PASS |
| 71 | +- Do not make test-only changes: PASS |
| 72 | +- Do not claim PASS unless user-facing Create Account page works manually: PASS |
| 73 | +- Add safe visible operator diagnostics for `POST /api/auth/create-account`: PASS |
| 74 | +- Diagnostic includes selected auth provider: PASS |
| 75 | +- Diagnostic includes DB provider: PASS |
| 76 | +- Diagnostic includes Supabase configured yes/no: PASS |
| 77 | +- Diagnostic includes identity tables ready yes/no: PASS |
| 78 | +- Diagnostic includes exact upstream status code: PASS |
| 79 | +- Diagnostic includes safe error code/message: PASS |
| 80 | +- Do not print secrets: PASS |
| 81 | +- Fix runtime cause shown by diagnostics: PASS; the live runtime path is ready and repeated-email upstream failures are now diagnosable without secret leakage. |
| 82 | +- Keep `GAMEFOUNDRY_DB_PROVIDER=local-db`: PASS |
| 83 | +- Product data remains Local DB: PASS |
| 84 | +- No password tables: PASS |
| 85 | +- No browser-owned auth/provider logic: PASS |
| 86 | +- No silent fallback: PASS |
| 87 | + |
| 88 | +## Validation Performed |
| 89 | + |
| 90 | +- `node --check src/dev-runtime/server/local-api-router.mjs` - PASS |
| 91 | +- `node --check src/dev-runtime/auth/provider-contract-stubs.mjs` - PASS |
| 92 | +- `node --check scripts/start-local-api-server.mjs` - PASS |
| 93 | +- `npm run validate:supabase-dev` - PASS with expected advisory direct PostgreSQL TLS WARN; REST/API identity readiness passed. |
| 94 | +- `npm run dev:local-api` - PASS; server started at `http://127.0.0.1:5501/`. |
| 95 | +- Manual browser Create Account repeated-email diagnostic validation - PASS. |
| 96 | +- Manual browser Create Account fresh account and Sign In validation - PASS. |
| 97 | +- `npx playwright test tests/playwright/tools/LoginSessionMode.spec.mjs --project=playwright --workers=1 --reporter=list --grep "Configured account auth actions|Create Account shows generic"` - PASS, 2 tests. |
| 98 | +- `npm run test:workspace-v2` - PASS, 5 Playwright tests. |
| 99 | + |
| 100 | +## Validation Notes |
| 101 | + |
| 102 | +- `node --test tests/dev-runtime/SupabaseProviderContractStub.test.mjs` and a narrowed `--test-name-pattern` attempt both timed out in this environment before producing TAP output. This was not counted as PASS. |
| 103 | +- Full samples smoke was skipped because the PR is limited to account auth diagnostics/runtime behavior and does not change sample runtime behavior. |
| 104 | + |
| 105 | +## Impacted Lanes |
| 106 | + |
| 107 | +- runtime |
| 108 | +- integration |
| 109 | +- account/auth session |
| 110 | + |
| 111 | +## Changed Files |
| 112 | + |
| 113 | +- `src/dev-runtime/auth/provider-contract-stubs.mjs` |
| 114 | +- `src/dev-runtime/server/local-api-router.mjs` |
| 115 | +- `docs_build/dev/reports/PR_26166_163-create-account-live-diagnostic-fix.md` |
| 116 | +- `docs_build/dev/reports/PR_26166_163-local-api-console.txt` |
| 117 | +- `docs_build/dev/reports/PR_26166_163-local-api-console-errors.txt` |
| 118 | +- `docs_build/dev/reports/codex_review.diff` |
| 119 | +- `docs_build/dev/reports/codex_changed_files.txt` |
| 120 | +- Validation reports regenerated by `npm run test:workspace-v2` |
| 121 | + |
0 commit comments