PRACTICAL FIELD GUIDE

404 on a record that exists: not found or not owned?

A 404 can represent a missing record or a record outside the end user's owner scope. This avoids revealing another user's row through the existence of an error distinction.

MCPBackend editorial team · · Examples are illustrative

The short answer

When a table uses owner row security, MCPBackend adds the caller's user ID to every query. A row that belongs to someone else is simply not in the result, so GET /v1/{projectId}/db/{table}/{id} and PATCH both answer 404 with code not_found, exactly as if the row did not exist. That is intentional: a different error would tell an attacker which IDs are real.

How to tell the two cases apart

  • Repeat the request with a server-side API key that has read permission on the table. API keys bypass row policies, so if the key sees the row and the user token does not, ownership is the cause.
  • Check the owner column on that row against the user ID in the caller's token.
  • Confirm the project ID and table name in the URL: a request to the wrong project also returns 404.
  • Note that DELETE behaves differently: it returns 204 whether or not a row was visible, so do not use a delete to test ownership.

Put it into practice

  1. Confirm the table, primary key and project in the request.
  2. Check the intended caller and inspect the record through an authorized administrative path when appropriate.
  3. Test a known owned record and a known non-owned record to validate the policy behavior.

What this looks like

ILLUSTRATIVE EXAMPLE

A second test user requests the first user's task ID and receives 404. The row exists, but it is not visible to that user.

A boundary to keep clear

Do not widen read access just to make a troubleshooting request return the row.

MCPBackend context

Use get_project_api or the dashboard's generated OpenAPI contract for your project's exact data-plane routes. Machine keys and end-user tokens have different access models. Treat error status and JSON code together, keep credentials out of URLs, and test against disposable records before changing real data.

Take the next step

Inspect the current project contract, try the change with disposable data, and verify the result through the same credentials your app will use. Record the expected response and one denied-access case before release.

Frequently asked questions

Why not return 403 Forbidden for someone else's record?

A 403 would confirm that the record exists. Returning 404 for both cases keeps record IDs from leaking between users, which is the usual choice for row-level security.

Should I switch the table to public read to debug this?

No. Use a server-side key or the dashboard to inspect the row, and keep the policy as it is.

Sources and further reading

These references explain the underlying protocols and design principles. For supported MCPBackend operations and exact request shapes, inspect your project’s generated API contract.