Skip to content

fix(storage): ensure storage_url has trailing slash in client initialization#1395

Open
mebishnusahu0595 wants to merge 1 commit intosupabase:mainfrom
mebishnusahu0595:fix/storage-url-trailing-slash
Open

fix(storage): ensure storage_url has trailing slash in client initialization#1395
mebishnusahu0595 wants to merge 1 commit intosupabase:mainfrom
mebishnusahu0595:fix/storage-url-trailing-slash

Conversation

@mebishnusahu0595
Copy link

@mebishnusahu0595 mebishnusahu0595 commented Feb 12, 2026

Fixes #1396

Summary

Ensures that storage_url created in client initialization always includes a trailing slash.

Problem

storage_url was created without a trailing slash (e.g., .../storage/v1), which caused warnings in storage3 when interacting with buckets (which expects .../storage/v1/).

Solution

Explicitly normalize storage_url during client initialization in both Sync and Async clients to ensure it always ends with / by using URL(f"{path}/"). This handles both base URLs with and without trailing slashes correctly without creating double slashes.

Tests

Added src/supabase/tests/test_storage_url.py which verifies:

  • storage_url has a trailing slash for Client (Sync).
  • storage_url has a trailing slash for AsyncClient.
  • Correct behavior regardless of whether supabase_url provided to the constructor ends with a slash or not.

Summary by CodeRabbit

  • Bug Fixes

    • Corrected storage URL construction to consistently include a trailing slash across both sync and async clients.
  • Tests

    • Added unit tests validating proper storage URL formatting with various base URL configurations.

@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

This PR fixes a bug where the Python SDK's storage_url was constructed without a trailing slash, causing storage3 to emit warnings. Both sync and async clients now ensure storage_url ends with a trailing slash using explicit URL construction instead of joinpath with an empty segment.

Changes

Cohort / File(s) Summary
Client storage_url construction
src/supabase/src/supabase/_async/client.py, src/supabase/src/supabase/_sync/client.py
Modified storage_url assignment to ensure trailing slash by using URL(f"{self.supabase_url.joinpath('storage', 'v1')}/") instead of joinpath(..., ""), guaranteeing consistent URL formatting across both client implementations.
Storage URL validation tests
src/supabase/tests/test_storage_url.py
Added 52 lines of unit tests validating that storage_url ends with a trailing slash for sync and async clients, testing both create_client/AsyncClient.create factory methods and direct constructor calls.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • o-santi
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: ensuring storage_url has a trailing slash during client initialization, which is the core fix in this PR.
Linked Issues check ✅ Passed The PR fully addresses issue #42729 by ensuring storage_url includes a trailing slash in both sync and async clients, eliminating storage3 warnings and log pollution.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing storage_url trailing slash handling: client initialization updates in both sync/async clients and comprehensive test coverage with no unrelated modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Python create_client sets storage_url without trailing slash and storage3 complains about it

1 participant