Skip to content

Importing AClientOptions and using it as-is is usually wrong #929

@jfeaver

Description

@jfeaver

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

When I import AClientOptions as the default options to pass to acreate_client() then I get an asynchronous client with a synchronous storage client back and run into errors like this:

  File "/Users/jfeaver/proj/public-api/public_api/dependencies/get_supabase.py", line 32, in get_supabase_from_cookie
    await supabase.auth.set_session(
  File "/Users/jfeaver/Library/Caches/pypoetry/virtualenvs/public-api-odHRiFV8-py3.12/lib/python3.12/site-packages/gotrue/_async/gotrue_client.py", line 587, in set_session
    await self._save_session(session)
  File "/Users/jfeaver/Library/Caches/pypoetry/virtualenvs/public-api-odHRiFV8-py3.12/lib/python3.12/site-packages/gotrue/_async/gotrue_client.py", line 905, in _save_session
    await result
TypeError: object NoneType can't be used in 'await' expression

To Reproduce

  1. Create a client with acreate_client and pass options as AClientOptions():
from supabase import AClient, AClientOptions, acreate_client

supabase = await acreate_client(url, anon_jwt, options=AClientOptions())
  1. Use that supabase client to make queries or other operations like:
await supabase.auth.set_session(...)
  1. Observe the error.

Expected behavior

The AClientOptions should use only asynchronous clients so that they can be used as-is to build an asynchronous client.

System information

  • OS: MacOS 14.3.1 (23D60)
  • Version of supabase-py: 2.7.4

Additional context

I want to pass in AClientOptions() rather than relying on the default options of the library because I sometimes want to pass in options and sometimes don't and I do this with a shared function so the shared code always passes in options to acreate_client.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions