|
Ran
|
Jobs
10
|
Files
120
|
Run time
1min
|
Badge
README BADGES
|
push
github
fix(postgrest): enforce maybeSingle() client-side for all request methods (#1779) ## What kind of change does this PR introduce? Bug fix. ## What is the current behavior? `maybeSingle()` only avoids the `application/vnd.pgrst.object+json` Accept header for GET requests. For every other method, for example `.insert(...).select().maybeSingle()` or an update, the header is still sent, so a request matching zero rows makes PostgREST answer with a real 406 that shows up in the project's API logs. The client then swallows that 406 by string-matching `Results contain 0 rows` in the error details. This is the remaining half of #560, which the previous workaround explicitly called out as unfixed: https://github.com/supabase/supabase-flutter/blob/effc37d52/packages/postgrest/lib/src/postgrest_transform_builder.dart#L209-L210 ## What is the new behavior? `maybeSingle()` no longer overrides the Accept header at all. The result is fetched as a plain JSON list for every request method and the at-most-one-row constraint is enforced client-side: one row resolves to that row, zero rows resolve to `null`, and more than one row throws a 406 `PostgrestApiException` with error code `PGRST116`, mirroring PostgREST's own error. No 406 ever reaches the server, so nothing pollutes the API logs. This matches how supabase-js fixed the same problem (supabase/postgrest-js#361), and it allows removing the brittle `_handleMaybeSingleError` fallback that string-matched error details. The synthesized multiple-rows error now also carries `errorCode: 'PGRST116'`, which the previous client-side error left unset. ## Additional context The mock tests in `maybe_single_test.dart` simulated the old server-generated 406 responses and were rewritten to cover the new behavior: no Accept override for reads or writes, zero rows with `count()` resolving to `null` data and count 0, a client-side 406 on a multi-row write, and a genuine server error surfaci... (continued)
1 of 1 new or added line in 1 file covered. (100.0%)
1 existing line in 1 file now uncovered.6041 of 6819 relevant lines covered (88.59%)
4.58 hits per line
| Lines | Coverage | ∆ | File |
|---|---|---|---|
| 1 |
81.06 |
0.38% | packages/postgrest/lib/src/postgrest_builder.dart |
| ID | Job ID | Ran | Files | Coverage | |
|---|---|---|---|---|---|
| 3 | supabase_functions - 33181427034.3 | 4 |
93.81 |
GitHub Action Run | |
| 4 | supabase_realtime - 33181427034.4 | 13 |
90.27 |
GitHub Action Run | |
| 5 | supabase_storage - 33181427034.5 | 9 |
97.35 |
GitHub Action Run | |
| 6 | supabase_flutter - 33181427034.6 | 11 |
82.22 |
GitHub Action Run | |
| 7 | supabase_auth - 33181427034.7 | 30 |
90.62 |
GitHub Action Run | |
| 8 | iceberg - 33181427034.8 | 6 |
68.52 |
GitHub Action Run | |
| 9 | supabase - 33181427034.9 | 14 |
93.49 |
GitHub Action Run | |
| 10 | postgrest - 33181427034.10 | 11 |
84.75 |
GitHub Action Run | |
| 5 | yet_another_json_isolate - 32956931006.5 | 1 |
98.44 |
GitHub Action Run | |
| 9 | supabase_common - 32951661159.9 | 21 |
86.96 |
GitHub Action Run |
| Coverage | ∆ | File | Lines | Relevant | Covered | Missed | Hits/Line |
|---|