Repository navigation
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 1 minute. 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-2676-realtime-remove-unused-asyncrealtimeclient_leave_open_topic
branch
November 3, 2026 13:10
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.
Resolves SDK-2676.
What
Removes
AsyncRealtimeClient._leave_open_topic(). Nothing called it, so coverage always reported it as uncovered. Also removes theAsyncMockstub for it intests/test_presence.py.Why delete instead of wiring it up
channel(). In realtime-js v2 (and in phoenix.js, where it comes from), the only caller of_leaveOpenTopicwasRealtimeChannel._rejoin().channel()returned the existing channel for the topic. realtime-js removed it in feat(realtime): use phoenix's js lib inside realtime-js supabase-js#2119 when it switched to phoenix's JS client.git log -S _leave_open_topicshows that cfbe594 (fix(realtime): ammend reconnect logic to not unsubscribe #1346, "ammend reconnect logic to not unsubscribe") replaced the call in_rejoin()with a log line. During a reconnect the helper found the rejoining channel itself and unsubscribed it. The method has been dead since then. Its only other appearance is the test stub added in 6be6c0c.self.channelsis a dict keyed by topic, so the helper could only ever matchself.channels[topic], which is the channel being joined. Whenchannel()replaces a leaving channel, the old instance is dropped from the dict and is already leaving, not joined or joining._remove_channel()only deletes the entry if it is still the same instance, so the replacement is safe without this helper.Testing
git grep leave_openreturns nothing.make ruffis clean.uv run --frozen --package realtime pytest testsgives 116 passed, includingtest_channel_rejoin.py,test_subscription_status.pyandtest_presence.py.uv run --frozen --package realtime mypy src/realtime testsreports no issues.Review
I reviewed the diff with
/code-review(high effort). It found no issues, so nothing changed.