Skip to content

feat(postgrest): report an embed without a relationship as UndefinedRelationship - #1031

Merged
Tr00d merged 1 commit into
masterfrom
feat/postgrest-reason-pgrst200
Dec 2, 2026
Merged

Tr00d merged 1 commit into
masterfrom
feat/postgrest-reason-pgrst200

Conversation

@Tr00d

@Tr00d Tr00d commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Summary

A query that embeds a table PostgREST finds no relationship to now throws PostgrestException with Reason = FailureHint.Reason.UndefinedRelationship instead of Unknown. That includes a table in another schema: PostgREST resolves embeds within the schema of the request only.

Public API

// FailureHint.Reason
UndefinedRelationship   // = 13, appended; existing values keep their ordinals
try
{
    await client.WithSchema("personal").Table<User>().Embed(RelatedRows.Of("messages")).Get();
}
catch (PostgrestException e) when (e.Reason == FailureHint.Reason.UndefinedRelationship)
{
}

Behavior

  • HTTP 400 with PostgREST code PGRST200 ("Could not find a relationship between … in the schema cache") maps to UndefinedRelationship.
  • Any other 400 keeps its current mapping (MaxAffectedExceeded for PGRST124, otherwise Unknown).
  • Additive: a caller that switched on Unknown for this answer sees the new reason.

Deviations from supabase-js

None; supabase-js surfaces the PostgREST error code as-is, which this reason names.

Tests

Tier Class Pins
E2E EmbedTests Embedding public.messages from a personal client answers UndefinedRelationship
Contract FailureReasonTests PGRST200 maps to UndefinedRelationship; another 400 stays Unknown

Both new tests failed before the mapping (the reason was Unknown).

Diff coverage: 100% (1 line). Mutation: 1 killed of 1 tested on changed lines, 0 survivors.

@Tr00d
Tr00d marked this pull request as ready for review December 2, 2026 10:22
@Tr00d
Tr00d merged commit 45d3d36 into master Dec 2, 2026
11 checks passed
@Tr00d
Tr00d deleted the feat/postgrest-reason-pgrst200 branch December 2, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant