Separate the failure stages
Work through these steps in order. Each one builds on the last, so resist skipping ahead even if a step feels familiar.
- Log the shape of safe, non-sensitive client state before the request.
- Check the browser network response and status code.
- Confirm the table and column names match the current schema.
- Test the same user against the insert or select policy.
- Handle the returned error before showing success in the UI.
Common causes
Use the list below as a working checklist. Each item is something you can verify or action directly on your own site.
- A required column is missing or has the wrong type.
- The request role has no table grant.
- RLS allows reading but not inserting, or filters out the inserted row.
- A query selects columns that no longer exist.
- Realtime is not enabled for the table or the subscription filter is wrong.
- Storage policies allow upload but not read of the resulting object.
Make the UI honest
Only show a success state after the database response succeeds. Keep loading, empty, error and retry states distinct so visitors do not resubmit a request that already worked.
Security reminder
Do not put private service credentials in client code. Use the backend or a server-side function for privileged operations and return only the data the UI needs.
Data loss checklist before shipping a fix
Here are the key things to get right. None of them are complicated on their own, but skipping one tends to undermine the rest.
- Confirm the failed submission is actually gone, rather than saved but not displayed.
- Check whether a unique constraint silently rejected a duplicate submission.
- Confirm the client is reading the insert response for errors, not only for a network success status.
- Check whether a trigger or edge function failed after the row was already inserted.
- Verify timezone handling on any date column used for ordering or filtering.
Recovery sequence
Here is the process broken into clear steps. Take them one at a time and check each off before continuing.
- Reproduce the failure with the exact user account and payload that failed.
- Check the database logs for the rejected query and its error code.
- Fix the schema, grant or policy causing the rejection.
- Re-test the same payload end to end, including the success state shown to the user.
- Add a test case for this exact failure so a future schema change does not reintroduce it.