Skip to content

fix(client_options): honor False for boolean options in replace()#1516

Merged
o-santi merged 2 commits into
supabase:mainfrom
JSap0914:fix/client-options-replace-false
Jul 9, 2026
Merged

fix(client_options): honor False for boolean options in replace()#1516
o-santi merged 2 commits into
supabase:mainfrom
JSap0914:fix/client-options-replace-false

Conversation

@JSap0914

Copy link
Copy Markdown
Contributor

Bug

ClientOptions.replace() builds the boolean options with the param or self.param idiom:

client_options.auto_refresh_token = auto_refresh_token or self.auto_refresh_token
client_options.persist_session = persist_session or self.persist_session

Because False or x == x, passing False is silently discarded. As a result you cannot disable auto_refresh_token or persist_session through replace() — the original value is always kept. This affects both AsyncClientOptions.replace() and SyncClientOptions.replace().

Fix

Use an explicit None check so an explicitly-passed False is honored while an omitted argument still falls back to the current value:

client_options.auto_refresh_token = (
    auto_refresh_token if auto_refresh_token is not None else self.auto_refresh_token
)
client_options.persist_session = (
    persist_session if persist_session is not None else self.persist_session
)

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.py covering both sync and async options:

pytest src/supabase/tests/test_client_options.py -q
5 passed

The new tests fail on main (assert True is False) and pass with this change.

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.
Copilot AI review requested due to automatic review settings June 16, 2026 02:37
@JSap0914 JSap0914 requested review from a team and o-santi as code owners June 16, 2026 02:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 treat False as a valid override by checking is not None.
  • Add tests ensuring auto_refresh_token=False and persist_session=False are 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 o-santi merged commit 10fb8f9 into supabase:main Jul 9, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants