Skip to content

Commit 7b026f1

Browse files
committed
Fix Supabase auth preflight selection diagnostics before users roles cutover - PR_26166_144-supabase-auth-preflight-selection-fix
1 parent 264783d commit 7b026f1

9 files changed

Lines changed: 837 additions & 1546 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ docs/dev/reports/playwright_v8_coverage_report.txt
3636

3737
*.mp4
3838
*.mkv
39+
40+
.env.local
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# PR_26166_144 Supabase Auth Preflight Selection Fix
2+
3+
## Branch Validation
4+
5+
- Current branch: `main`
6+
- Expected branch: `main`
7+
- Result: PASS
8+
9+
## Summary
10+
11+
Updated auth/provider diagnostics so Supabase configuration, provider selection, and connectivity are distinct states.
12+
13+
- `/api/auth/status` now reports `status=provider-not-selected` when Supabase config exists but `GAMEFOUNDRY_AUTH_PROVIDER=local-db`.
14+
- Browser-facing unavailable text remains generic: `The site is currently unavailable. Please try again later.`
15+
- Operator diagnostics may state provider selection and the required auth-provider env switch.
16+
- Added safe operator preflight route: `GET /api/auth/operator-preflight`.
17+
- Operator preflight checks Supabase Auth connectivity without switching product data away from `GAMEFOUNDRY_DB_PROVIDER=local-db`.
18+
- No migrations, secrets, product-table writes, or auth cutover were added.
19+
20+
Delta ZIP: `tmp/PR_26166_144-supabase-auth-preflight-selection-fix_delta.zip`
21+
22+
## Requirement Checklist
23+
24+
| Requirement | Result | Evidence |
25+
| --- | --- | --- |
26+
| Main branch only | PASS | `git branch --show-current` returned `main`. |
27+
| Read `PROJECT_INSTRUCTIONS.md` | PASS | Read before changes. |
28+
| Do not migrate users/roles/user_roles/product tables | PASS | No migration or schema code changed. |
29+
| Do not add secrets | PASS | No secret values added; `.env.local` remains local-only and is not packaged. |
30+
| Do not commit `.env` files | PASS | No `.env` file is included in review artifacts or delta ZIP. |
31+
| Keep `GAMEFOUNDRY_DB_PROVIDER=local-db` | PASS | Operator preflight reports `localDbProductDataActive=true`; tests keep product DB local. |
32+
| Distinguish Supabase config present | PASS | `/api/auth/status` and operator preflight expose `supabaseConfigPresent`. |
33+
| Distinguish Supabase provider selected | PASS | Diagnostics expose `supabaseProviderSelected`. |
34+
| Distinguish Supabase provider not selected | PASS | Diagnostics expose `supabaseProviderNotSelected`; Local DB selected path reports `provider-not-selected`. |
35+
| Distinguish connectivity healthy | PASS | Operator preflight returns `connectivityStatus=healthy` in fake healthy path. |
36+
| Distinguish connectivity failed | PASS | Operator preflight returns `connectivityStatus=failed` and sanitized HTTP status in wrong-key path. |
37+
| `/api/auth/status` not misleading when config exists but Local DB auth selected | PASS | Sanitized local check returned `configured=true`, `status=provider-not-selected`, `supabaseProviderSelected=false`, `ready=false`. |
38+
| Add safe operator-only preflight path/command | PASS | Added `GET /api/auth/operator-preflight`; report documents local command evidence. |
39+
| Browser-facing message remains generic | PASS | Non-ready status still returns `The site is currently unavailable. Please try again later.` |
40+
| Operator diagnostics may state selected provider/env switch | PASS | `operatorDiagnostic` states selected auth provider and `GAMEFOUNDRY_AUTH_PROVIDER=supabase-auth` switch. |
41+
| No browser-visible secrets | PASS | Tests assert preflight/status payloads do not contain fake key values. |
42+
| No silent fallback | PASS | Diagnostics keep `noAutomaticFallback=true`; missing/wrong config fails visibly. |
43+
44+
## Validation Lane Report
45+
46+
- Impacted lane: auth/provider contract and browser-facing auth status route.
47+
- Runtime JavaScript changed: Yes, server-side Local API router.
48+
- Playwright impacted: Yes, because `/api/auth/status` is browser-facing route behavior.
49+
- Samples: SKIP. No samples or game runtime changed.
50+
- Migrations/schema: SKIP. Explicitly out of scope.
51+
- Auth cutover: SKIP. Explicitly out of scope.
52+
53+
## Validation Performed
54+
55+
- PASS: `node --check src/dev-runtime/server/local-api-router.mjs`
56+
- PASS: `node --check tests/dev-runtime/SupabaseProviderContractStub.test.mjs`
57+
- PASS: `node --test tests/dev-runtime/SupabaseProviderContractStub.test.mjs` passed 17/17 tests.
58+
- PASS: `npx playwright test tests/playwright/tools/LoginSessionMode.spec.mjs tests/playwright/tools/StaticOnlyLoginApiRequired.spec.mjs tests/playwright/tools/ApiStaticRouteRecovery.spec.mjs` passed 13/13 tests.
59+
- PASS: Sanitized local `.env.local` route check:
60+
- Local DB auth selected: `/api/auth/status` returned `configured=true`, `ready=false`, `status=provider-not-selected`, `supabaseConfigPresent=true`, `supabaseProviderSelected=false`, `supabaseConnectivityStatus=not-checked`, generic browser message.
61+
- Supabase Auth selected with Local DB product data: `/api/auth/status` returned `configured=true`, `ready=true`, `status=ready`, `supabaseProviderSelected=true`, `supabaseConnectivityStatus=not-checked`.
62+
- Operator preflight with current local env: `/api/auth/operator-preflight` returned `localDbProductDataActive=true`, `connectivityStatus=failed`.
63+
- PASS: `git diff --check` with line-ending warnings only.
64+
65+
## Playwright / V8 Coverage
66+
67+
- PASS: Targeted auth/session Playwright passed 13/13.
68+
- PASS/WARN: `docs_build/dev/reports/playwright_v8_coverage_report.txt` refreshed.
69+
- Server-side `src/dev-runtime/server/local-api-router.mjs` is listed as WARN because browser V8 coverage does not collect Node server modules; it is covered by the targeted Node provider tests and Playwright route behavior.
70+
71+
## Manual Validation Notes
72+
73+
1. Keep product DB local: set `GAMEFOUNDRY_DB_PROVIDER=local-db`.
74+
2. With Supabase config present and `GAMEFOUNDRY_AUTH_PROVIDER=local-db`, call `/api/auth/status`.
75+
3. Confirm response includes `status=provider-not-selected`, `supabaseConfigPresent=true`, `supabaseProviderSelected=false`, and the generic browser message.
76+
4. With `GAMEFOUNDRY_AUTH_PROVIDER=supabase-auth`, call `/api/auth/status`.
77+
5. Confirm response includes `status=ready` when config exists, with connectivity still `not-checked`.
78+
6. Call `/api/auth/operator-preflight` to validate live connectivity without switching product DB provider.
79+
7. Confirm the response reports connectivity as `healthy` or `failed` without exposing secret values.
80+
81+
## Notes
82+
83+
- Current local live operator preflight still reports Supabase connectivity failed. That is expected until the configured Supabase Auth/API key values are corrected; the purpose of this PR is to make that failure explicit without mislabeling provider-selection state or changing product data providers.
84+
Lines changed: 14 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,22 @@
1-
# git status --short
2-
M account/create-account.html
3-
M account/password-reset.html
4-
M account/sign-in.html
5-
M assets/theme-v2/js/account-auth-actions.js
6-
M assets/theme-v2/js/login-session.js
1+
# git status --short (excluding .env files)
2+
M .gitignore
73
M docs_build/dev/reports/codex_changed_files.txt
84
M docs_build/dev/reports/codex_review.diff
95
M docs_build/dev/reports/coverage_changed_js_guardrail.txt
10-
M docs_build/dev/reports/dependency_gating_report.md
11-
M docs_build/dev/reports/dependency_hydration_reuse_report.md
12-
M docs_build/dev/reports/execution_graph_reuse_report.md
13-
M docs_build/dev/reports/failure_fingerprint_report.md
14-
M docs_build/dev/reports/filesystem_scan_reduction_report.md
15-
M docs_build/dev/reports/incremental_validation_report.md
16-
M docs_build/dev/reports/lane_compilation_report.md
17-
M docs_build/dev/reports/lane_deduplication_report.md
18-
M docs_build/dev/reports/lane_input_validation_report.md
19-
M docs_build/dev/reports/lane_manifests/workspace-contract.json
20-
M docs_build/dev/reports/lane_runtime_optimization_report.md
21-
M docs_build/dev/reports/lane_snapshot_report.md
22-
M docs_build/dev/reports/lane_snapshots/workspace-contract.json
23-
M docs_build/dev/reports/lane_warm_start_report.md
24-
M docs_build/dev/reports/lane_warm_starts/workspace-contract.json
25-
M docs_build/dev/reports/monolith_trigger_removal_report.md
26-
M docs_build/dev/reports/persistent_lane_manifest_report.md
27-
M docs_build/dev/reports/playwright_discovery_ownership_report.md
28-
M docs_build/dev/reports/playwright_discovery_scope_report.md
29-
M docs_build/dev/reports/playwright_structure_audit.md
306
M docs_build/dev/reports/playwright_v8_coverage_report.txt
31-
M docs_build/dev/reports/retry_suppression_report.md
32-
M docs_build/dev/reports/slow_path_pruning_report.md
33-
M docs_build/dev/reports/static_validation_report.md
34-
M docs_build/dev/reports/targeted_file_manifest_report.md
35-
M docs_build/dev/reports/test_cleanup_performance_report.md
36-
M docs_build/dev/reports/test_cleanup_routing_report.md
37-
M docs_build/dev/reports/testing_lane_execution_report.md
38-
M docs_build/dev/reports/validation_cache_report.md
39-
M docs_build/dev/reports/zero_browser_preflight_report.md
407
M src/dev-runtime/server/local-api-router.mjs
418
M tests/dev-runtime/SupabaseProviderContractStub.test.mjs
42-
M tests/playwright/tools/ApiStaticRouteRecovery.spec.mjs
43-
M tests/playwright/tools/LoginSessionMode.spec.mjs
44-
M tests/playwright/tools/StaticOnlyLoginApiRequired.spec.mjs
45-
?? docs_build/dev/reports/PR_26166_142-auth-status-backend-contract.md
9+
?? docs_build/dev/reports/PR_26166_144-supabase-auth-preflight-selection-fix.md
10+
?? docs_build/dev/reports/supabase-preflight-report.md
4611

47-
# git ls-files --others --exclude-standard
48-
docs_build/dev/reports/PR_26166_142-auth-status-backend-contract.md
12+
# git ls-files --others --exclude-standard (excluding .env files)
13+
docs_build/dev/reports/PR_26166_144-supabase-auth-preflight-selection-fix.md
14+
docs_build/dev/reports/supabase-preflight-report.md
4915

50-
# git diff --stat
51-
account/create-account.html | 8 +-
52-
account/password-reset.html | 8 +-
53-
account/sign-in.html | 2 +-
54-
assets/theme-v2/js/account-auth-actions.js | 47 +-
55-
assets/theme-v2/js/login-session.js | 43 +-
56-
docs_build/dev/reports/codex_changed_files.txt | 94 +-
57-
docs_build/dev/reports/codex_review.diff | 2198 ++++++++------------
58-
.../dev/reports/coverage_changed_js_guardrail.txt | 8 +-
59-
docs_build/dev/reports/dependency_gating_report.md | 2 +-
60-
.../reports/dependency_hydration_reuse_report.md | 4 +-
61-
.../dev/reports/execution_graph_reuse_report.md | 4 +-
62-
.../dev/reports/failure_fingerprint_report.md | 2 +-
63-
.../reports/filesystem_scan_reduction_report.md | 2 +-
64-
.../dev/reports/incremental_validation_report.md | 2 +-
65-
docs_build/dev/reports/lane_compilation_report.md | 2 +-
66-
.../dev/reports/lane_deduplication_report.md | 2 +-
67-
.../dev/reports/lane_input_validation_report.md | 2 +-
68-
.../reports/lane_manifests/workspace-contract.json | 10 +-
69-
.../reports/lane_runtime_optimization_report.md | 2 +-
70-
docs_build/dev/reports/lane_snapshot_report.md | 4 +-
71-
.../reports/lane_snapshots/workspace-contract.json | 22 +-
72-
docs_build/dev/reports/lane_warm_start_report.md | 4 +-
73-
.../lane_warm_starts/workspace-contract.json | 16 +-
74-
.../dev/reports/monolith_trigger_removal_report.md | 2 +-
75-
.../dev/reports/persistent_lane_manifest_report.md | 6 +-
76-
.../playwright_discovery_ownership_report.md | 2 +-
77-
.../reports/playwright_discovery_scope_report.md | 2 +-
78-
.../dev/reports/playwright_structure_audit.md | 2 +-
79-
.../dev/reports/playwright_v8_coverage_report.txt | 47 +-
80-
docs_build/dev/reports/retry_suppression_report.md | 2 +-
81-
docs_build/dev/reports/slow_path_pruning_report.md | 12 +-
82-
docs_build/dev/reports/static_validation_report.md | 4 +-
83-
.../dev/reports/targeted_file_manifest_report.md | 4 +-
84-
.../dev/reports/test_cleanup_performance_report.md | 14 +-
85-
.../dev/reports/test_cleanup_routing_report.md | 2 +-
86-
.../dev/reports/testing_lane_execution_report.md | 16 +-
87-
docs_build/dev/reports/validation_cache_report.md | 30 +-
88-
.../dev/reports/zero_browser_preflight_report.md | 2 +-
89-
src/dev-runtime/server/local-api-router.mjs | 65 +-
90-
.../SupabaseProviderContractStub.test.mjs | 25 +-
91-
.../tools/ApiStaticRouteRecovery.spec.mjs | 1 +
92-
tests/playwright/tools/LoginSessionMode.spec.mjs | 18 +-
93-
.../tools/StaticOnlyLoginApiRequired.spec.mjs | 3 +-
94-
43 files changed, 1189 insertions(+), 1558 deletions(-)
16+
# git diff --stat (excluding .env files and review artifacts)
17+
.gitignore | 2 +
18+
.../dev/reports/coverage_changed_js_guardrail.txt | 1 -
19+
.../dev/reports/playwright_v8_coverage_report.txt | 2 -
20+
src/dev-runtime/server/local-api-router.mjs | 95 +++++++++++++++-
21+
.../SupabaseProviderContractStub.test.mjs | 125 ++++++++++++++++++++-
22+
5 files changed, 219 insertions(+), 6 deletions(-)

0 commit comments

Comments
 (0)