Repository navigation
fix(postgrest): reject strip_nulls combined with csv in either order - #1927
Merged
spydon merged 3 commits intoNov 3, 2026
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
spydon
deleted the
lukasklingsbo/sdk-2675-postgrest-strip_nullscsv-silently-drops-strip_nulls-while
branch
November 3, 2026 13:08
spydon
added a commit
that referenced
this pull request
Nov 3, 2026
…pabase (#1931) ## What Adds tests to the least-covered areas of supabase-py. No library code changes. Overall line coverage of library code (`--cov=src`, sync and async trees, with local infra) goes from about 91.3% to 98.6%: | Package | Before | After | | --------- | ------ | ----- | | auth | 89% | 98% | | storage | 91% | 99% | | postgrest | 94% | 99% | | realtime | 92% | 98% | | supabase | 92% | 98% | | functions | 99% | 99% | ## Tests added All new tests mock HTTP with `httpx.MockTransport`, or mock the websocket connection, so none of them need infra. - `src/storage/tests/test_vectors.py`: every vector bucket, index and vector operation (request paths, request bodies, omitted optional fields, the `delete` batch size limit, API error parsing), plus analytics bucket create, list and delete, and the missing-`pyiceberg` error. Runs against both the sync and async clients. - `src/auth/tests/_async/test_client_flows.py`: `initialize` from implicit grant URLs (query and fragment, recovery, error redirects, incomplete redirects), restoring and refreshing stored sessions, ID token, SSO and OAuth sign-in (including PKCE), code exchange, identity linking, reauthentication, MFA enroll, challenge, verify, unenroll and list, the "requires a session" errors, API error mapping, and pagination headers when listing OAuth clients. - `src/auth/tests/_async/test_jwks_and_refresh.py`: `get_claims` with real ES256 keys (JWKS caching and TTL, supplied JWKS, unknown key, empty JWKS, forged signature), retry scheduling on network errors, and the PKCE email change in `update_user`. - `src/realtime/tests/test_client_channels.py` and `test_channel_internals.py`: channel creation, replacement and removal, `set_auth`, send buffering, presence state and diff handling, join reply handling for postgres changes bindings, `join()`, the listen loop, connect retries and backoff, and send and heartbeat close handling. - `src/postgrest/tests/test_response_handling.py` and `test_builder_edges.py`: error mapping for `select`, `single`, `maybe_single` and `explain`, CSV and explain output, turning retries off, retrying GET requests (writes aren't retried, and retries stop at the limit), plus filter encodings (`fts` variants, `contained_by`, `ov`, `contains`, `sl`), `match`, `offset`, `range`, `upsert` and the deprecation warnings. - `src/supabase/tests/_async/test_client.py`: falling back to the API key when reading the session fails, and channel helper delegation. The auth and supabase sync tests are generated with `make <pkg>.build-sync`. ## Bugs found while writing these tests Each was filed and fixed in its own PR. This branch first pinned them with strict `xfail` tests, and those markers have been removed now that every fix is on `main`. - SDK-2667, #1919: `storage3.create_client()` always emitted the timeout `DeprecationWarning`. - SDK-2668, #1921: `MetadataConfiguration` rejected its Python field name. - SDK-2669, #1920: `set_session()` raised `IndexError` for an access token that isn't a JWT. - SDK-2670, #1923: implicit grant tokens in the URL fragment were ignored. - SDK-2671, #1922: `CodeExchangeParams` required `code_verifier`. - SDK-1674, #1925: `remove_all_channels()` left the channels registered. - SDK-2672, #1929: a join reply without matching `postgres_changes` silently dropped every postgres callback. - SDK-2673, #1928: `channel.join()` nested the config twice and left out the access token. - SDK-2674, #1926: `create_client()` didn't type-check the URL and key. - SDK-2675, #1927: `strip_nulls()` combined with `csv()` was only rejected in one call order. - SDK-2676, #1930: removed the unused `_leave_open_topic()`. Refs SDK-2666 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Tests** * Expanded synchronous and asynchronous coverage for authentication flows, session handling, JWT verification, refresh behavior, and OAuth/PKCE scenarios. * Added checks for database API requests, response and error handling, retry behavior, realtime channels and presence, and vector storage operations. * Added client-level checks for authorization fallback and realtime channel access. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes SDK-2675.
Problem
strip_nulls()refuses to run aftercsv(), but the opposite order was not checked.select("*").strip_nulls().csv()sent a plaintext/csvrequest and silently droppedstrip_nulls, becauseRequestConfig.send()only rewrites JSONAcceptheaders.strip_nulls().explain()had the same problem.Change
RequestConfig._reject_strip_nulls(method)raisesValueError("strip_nulls() cannot be used with <method>()")whenstrip_nullsis set.csv()overrides (the RPC builder inbase_request_builder.pyand the select builder in_async/, regenerated into_sync/) and the select builder'sexplain()call it before switching theAcceptheader.strip_nulls()stays. It is still reachable throughrpc(...).csv().strip_nulls(), since the RPC builder'scsv()returns the same builder.csv()returns a single request builder that has nostrip_nulls(), soselect("*").csv().strip_nulls()keeps failing withAttributeError(and is flagged by type checkers).Behaviour change:
strip_nulls().csv()andstrip_nulls().explain()used to run and ignorestrip_nulls. They now raiseValueErrorup front. Results did not change before, so callers relying on this only lose a no-op call.Comparison with postgrest-js
postgrest-js throws in
stripNulls()whenAcceptis alreadytext/csv, but itscsv()does not checkshouldStripNulls, sostripNulls().csv()is silently ignored there as well. This PR keeps the matchingcsv().strip_nulls()behaviour and also rejects the reverse order instead of ignoring it.Tests
tests/test_strip_nulls.pynow runs against both the sync and async clients with a mock transport. It covers both call orders on the select and RPC builders,strip_nulls().explain(), plus plaincsv()and plainstrip_nulls()(array and single object) requests.Self-review changes
A code review of the first revision led to:
strip_nulls().explain(), which dropped the flag the same way ascsv().RequestConfig._reject_strip_nulls.tests/test_strip_nulls.pyinstead of a second overlapping module, and running the existing header test on both clients.select().csv().strip_nulls()is rejected (AttributeErrororValueError) instead of locking inAttributeErroronly.