2f4d00c528
Deploy staging to test server / deploy (push) Successful in 6m34s
Align staging deployment, authentication, and admin access with the self-hosted identity boundary, including regression coverage and deployment diagnostics.
1.9 KiB
1.9 KiB
Debug Session: admin-payments-500
Status: [OPEN]
Symptom
Staging admin payment and package endpoints return HTTP 500. Confirmed example:
GET https://staging.jyotisha.chat/api/admin/payments?limit=20&offset=0
Constraints
- Do not modify business logic before runtime evidence identifies the root cause.
- Do not expose database URLs, JWTs, cookies, passwords, or keys.
- Preserve unrelated dirty workspace files.
Hypotheses
- Staging still runs an older SHA and the direct PostgreSQL fix is not deployed.
ADMIN_DATABASE_URLis absent or PostgreSQL is unreachable from the web container.admin_runtimelacks SELECT privileges on payment/package/identity tables.- Required staging migrations have not been applied.
- The SQL query does not match the staging schema.
Evidence Log
- Pre-fix staging health reports deployment SHA
dd8e2ad9c7e76d0152b4563c43a45b1e26137035. - Health reports both local business and identity databases as healthy; deployment drift and general database unreachability are rejected.
- SSH application logs are blocked because this workstation has no staging private key; no server stack trace is claimed.
- Static migration audit confirms
20260727020000_epay_packages_orders.sqlgrants payment objects only to Supabase roles, notadmin_runtime. - Both failing APIs use
ADMIN_DATABASE_URLthroughqueryAdminRows, so the missing grants and RLS policies explain the shared HTTP 500 failure.
Fix
Added forward migration 20260730010000_admin_payment_permissions.sql with least privilege:
- package SELECT/INSERT/UPDATE for
admin_runtime; - payment-order SELECT only;
- matching RLS policies;
- epay settings SELECT and save-function EXECUTE.
No API business logic was changed.
Verification
- Pre-fix contract test failed because the permission migration did not exist.
- Post-fix payment/package/epay contract suite: 21/21 passed.
- Staging migration and authenticated endpoint smoke are still pending.