fix(client_options): honor False for boolean options in replace()#1516
Merged
Conversation
ClientOptions.replace() used 'param or self.param' for auto_refresh_token and persist_session, so passing False was silently discarded (False or x == x) and these options could not be disabled via replace(). Use explicit 'param if param is not None else self.param' in both the async and sync replace() methods. Add regression tests.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds regression coverage and fixes ClientOptions.replace() / AClientOptions.replace() so explicit False boolean overrides are preserved rather than falling back to existing values.
Changes:
- Update
replace()logic to treatFalseas a valid override by checkingis not None. - Add tests ensuring
auto_refresh_token=Falseandpersist_session=Falseare honored for both sync and async client options.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/supabase/tests/test_client_options.py | Adds regression tests for boolean override behavior in replace() |
| src/supabase/src/supabase/lib/client_options.py | Fixes replace() to honor explicit False values for boolean options |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+80
to
+92
| async def test_replace_honors_false_for_boolean_aoptions(self) -> None: | ||
| options = AClientOptions( | ||
| auto_refresh_token=True, | ||
| persist_session=True, | ||
| ) | ||
|
|
||
| actual = options.replace( | ||
| auto_refresh_token=False, | ||
| persist_session=False, | ||
| ) | ||
|
|
||
| assert actual.auto_refresh_token is False | ||
| assert actual.persist_session is False |
| assert actual.auto_refresh_token is False | ||
| assert actual.persist_session is False | ||
|
|
||
| async def test_replace_honors_false_for_boolean_aoptions(self) -> None: |
o-santi
approved these changes
Jul 9, 2026
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.
Bug
ClientOptions.replace()builds the boolean options with theparam or self.paramidiom:Because
False or x == x, passingFalseis silently discarded. As a result you cannot disableauto_refresh_tokenorpersist_sessionthroughreplace()— the original value is always kept. This affects bothAsyncClientOptions.replace()andSyncClientOptions.replace().Fix
Use an explicit
Nonecheck so an explicitly-passedFalseis honored while an omitted argument still falls back to the current value:Defaults are unchanged and no validation is added. This is the minimal falsy-override fix only; it intentionally excludes the validation changes that were part of the now-closed #1398.
Verification
Added regression tests in
src/supabase/tests/test_client_options.pycovering both sync and async options:The new tests fail on
main(assert True is False) and pass with this change.