#50816·supabase

Nested inserts fail with `PGRST204 Could not find the '<child table>' column` while read embeds and plain inserts succeed

Author: pablogarciapdaCreated Sep 23, 2026Updated Sep 28, 2026
Labelsbugawaiting-detailsexternal-issue

Summary

On a hosted Supabase project, every nested insert (parent + child in one request) is rejected by PostgREST with PGRST204, even though the foreign key exists and is validated, read embeds on the same relationship work, and both the parent and child can be inserted separately.

This is project-wide: it reproduces on our own tables and on a freshly created parent/child pair.

Environment

  • Supabase hosted project ref: houuewkkodsfayinbbao
  • PostgREST reported by the error path: 14.5
  • Region: (fill in if relevant)
  • Client: @supabase/supabase-js via PostgREST over HTTPS

Steps to reproduce

Two tables in public with a normal, validated FK:

sql
create table parent_probe (id uuid primary key default gen_random_uuid(), name text not null);
create table child_probe (
  id uuid primary key default gen_random_uuid(),
  parent_id uuid not null references parent_probe(id) on delete cascade,
  name text not null
);

Then, authenticated with a valid user JWT whose RLS grants insert on both tables:

bash
# 1. Plain parent insert -> works
curl -X POST "$URL/rest/v1/parent_probe" \
  -H "apikey: $PUBLISHABLE" -H "Authorization: Bearer $JWT" \
  -H "Content-Type: application/json" -H "Prefer: return=representation" \
  -d '{"name":"p"}'
# 201 Created

# 2. Nested insert -> fails
curl -X POST "$URL/rest/v1/parent_probe" \
  -H "apikey: $PUBLISHABLE" -H "Authorization: Bearer $JWT" \
  -H "Content-Type: application/json" -H "Prefer: return=representation" \
  -d '{"name":"p","child_probe":[{"name":"c"}]}'
# 400 Bad Request
# {"code":"PGRST204","details":null,"hint":null,
#  "message":"Could not find the 'child_probe' column of 'parent_probe' in the schema cache"}

Expected

The nested insert creates the parent and its children in one transaction, exactly like the equivalent read embed resolves the relationship.

Actual

PostgREST treats the embedded resource name as a column of the parent table and returns PGRST204.

Evidence

Probe Result
FK exists and is validated (pg_constraint, convalidated = true) ✅
Read embed GET /parent_probe?select=id,child_probe(id) ✅ 200, children returned
Plain parent insert ✅ 201
Direct child insert ✅ 201
Nested insert (parent + children) ❌ 400 PGRST204
Same nested insert on a freshly created pair ❌ 400 PGRST204

Real-world tables show the same behaviour (workouts + workout_exercises, groups + group_members, tenants + tenant_modules), so it is not specific to one schema.

What we tried (none of it helped)

  • notify pgrst, 'reload schema'
  • notify pgrst, 'reload config'
  • notify pgrst, 'reload tables'
  • notify pgrst, 'reload relationships'
  • Re-adding the foreign key constraint
  • Restarting the project's Data API (toggling it off/on)
  • pg_notification_queue_usage() returns 0

The schema cache is otherwise provably fresh: a new table COMMENT shows up in GET /rest/v1/ immediately, and read embeds on the same relationship resolve correctly. The FK relationship is therefore known to PostgREST for reads but not for writes.

Impact

Nested inserts are completely unusable on this project. Any application that creates a parent with its children in one request is broken — in our case it means workouts can never be created. The workaround is an RPC that performs both inserts inside one SQL function, which we have adopted, but the PostgREST behaviour still looks incorrect.

Additional context

This matches other reports of schema-cache/relationship corruption on specific projects (e.g. supabase/supabase#42183, supabase/supabase#39446), where the documented remedy — restarting the Data API — also did not resolve it.

If it helps, we can grant temporary read access to the project for triage.