parity(postgrest): return structured error for non-JSON body on successful 2xx responses [from supabase-js]

Open
#260 0 comments 0 reactions 1 assignee View on GitHub

@Tr00d is already working on this.

Since Jul 1, 2026.

Assessment

This issue has not been assessed yet.

Description

parity

SDK Parity: C# implementation needed

Reference Implementation (supabase-js)

What Changed

When a PostgREST request returns 2xx but the body is not valid JSON (e.g., HTML 502 from a proxy), the SDK was throwing an unhandled JsonException. Fix: catch the JSON parse failure and return a structured PostgrestError with the raw body as the message.

Code Reference
try {
  data = JSON.parse(body)
} catch {
  error = { message: body }  // raw body → error message
  data = null
}
Expected Behaviors
HTTP 200 with "<html>502 Bad Gateway</html>"
→ PostgrestResponse { Data = null, Error = PostgrestError(Message = "<html>...") }
NOT: throws JsonException

Acceptance Criteria

  • Non-JSON 2xx body returns PostgrestError (not thrown exception)
  • HTTP status preserved
  • Tests cover HTML body on 200

Context


Generated with Claude Code /sync-sdk-parity

Dominant language
C#
Stars
701
Forks
106
Avg merge
16h 35m
Merged PRs (30d)
45

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from supabase/supabase-csharp

All issues in supabase/supabase-csharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.