Skip to content

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

Closed

Description

@grdsdev

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

Activity

  1. self-assigned this
    on Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions