Repository navigation
Improve client validation and ClientOptions.replace correctness - #1398
AhmedAli58 wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Cache: Disabled due to Reviews > Disable Cache setting Disabled knowledge base sources:
📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR centralizes input validation by adding _validate_client_inputs(...) and calling it from both AsyncClient.init and Client.init. It refactors ClientOptions.replace (async and sync) to use explicit None-based merging, adds function_client_timeout and makes several timeout parameters Optional. Tests were updated: incorrect-values client tests were parameterized and now use pytest.raises for exceptions; a regression test test_storage_base_url_has_trailing_slash was added to both sync and async test modules (duplicated in the sync file); new tests cover ClientOptions.replace behaviors (falsy values, header copying, function_client_timeout). Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
|
I don't think this is needed, as the code is fully type checked. If the user passes in a non-string as the url, |
Summary
This PR introduces three targeted quality improvements in the
supabasepackage:ClientOptions.replace().ClientOptions.replace().All changes are covered by tests. Linting and the full test suite pass.
1. Strengthened Client Input Validation
Problem
Constructor validation for
supabase_urlandsupabase_keywas inconsistent. Non-string or invalid values could raise rawTypeErroror bypass validation, resulting in low-quality or unclear errors.Changes
SupabaseExceptionpytest.raisesinstead of weakxfailpatternsImpact
Invalid constructor inputs now fail deterministically and consistently with clear exceptions.
2. Fixed Falsy Override Handling in
ClientOptions.replace()Problem
or-based assignment caused explicit falsy values (False,0,{}) to be ignored, silently preserving previous configuration values.Changes
orlogic with explicitis NonechecksImpact
Callers can now reliably override configuration with valid falsy values.
3. Fixed Configuration Integrity Gaps in
ClientOptions.replace()Problems
function_client_timeoutwas not preserved or correctly overridden.Changes
function_client_timeoutin both async and sync implementations.Impact
Replaced option objects are now configuration-safe and free from unintended mutation coupling.
Testing
make ruff-> passedmake supabase.tests-> 55 tests passedScope
ClientOptions.replace()implementations (async and sync)Validation Checklist