Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks done
jfeaver opened this issue Sep 24, 2024 · 0 comments · Fixed by #918
Closed
2 tasks done

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

jfeaver opened this issue Sep 24, 2024 · 0 comments · Fixed by #918
Assignees
Labels
bug Something isn't working

Comments

@jfeaver
Copy link

jfeaver commented Sep 24, 2024

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.

@jfeaver jfeaver added the bug Something isn't working label Sep 24, 2024
@silentworks silentworks self-assigned this Sep 26, 2024
@silentworks silentworks linked a pull request Sep 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants