Closed
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
A clear and concise description of what the bug is.
Mutable reference options.headers
options.headers
is updated in create_client
directry. thats why, The headers may be changed unintentionally if it is shared
ClientOptions` instance other position.
To Reproduce
Please execute below source code jupytor notebook.
from supabase import create_client
from supabase.lib.client_options import SyncClientOptions
class settings:
SUPABASE_URL = "https://***"
SUPABASE_KEY = "***"
from supabase._sync.client import create_client, ClientOptions
from gotrue import SyncMemoryStorage
# Share same ClientOptions Instanc
shared_options = ClientOptions(storage=SyncMemoryStorage(), headers={"Custom-Header": "InitialValue"})
# Create client1
client1 = create_client(settings.SUPABASE_URL, settings.SUPABASE_KEY, options=shared_options)
# Create client2
client2 = create_client(settings.SUPABASE_URL, settings.SUPABASE_KEY, options=shared_options)
# Rewrite header client1
client1.options.headers["Custom-Header"] = "ModifiedValue"
client2.options.headers["Custom-Header"] = "ModifiedValue2"
# Check header client2
print(client1.options.headers["Custom-Header"]) # "ModifiedValue2"
Expected behavior
...
print(client1.options.headers["Custom-Header"])
# -> "ModifiedValue"
Screenshots

System information
- mac OS
- chrome
- Version of supabase-py: 2.15.0
- Version of Python: 3.9.0