Skip to content

potential bug: set_auth can throw, should the AsyncClient handle it? #1144

Open
@spygi

Description

@spygi

Bug report

  • I confirm this is a bug with Supabase, not with my own application. - To be discussed, might be by-design.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

The call to Realtime Async client to set_auth can raise a ValueError if the access token is not valid:

https://github.com/supabase/supabase-py/blob/main/supabase/_async/client.py#L307

This is not handled by the AsyncClient resulting in the user being logged in but this exception in the terminal:

Image

To Reproduce

  • In my user flow, I create an anonymous user initially and once the user gives an email I update the previous user (to keep the same uid and all logs correlated).
  • Somehow this corrupts the access token (I know this flow is not intended but a ValueError can happen on JWT expiration too etc if I understand the code correctly)
  • When I programmatically await supabase.auth.verify_otp user is logged in but the ValueError is shown on my terminal.

Expected behavior

I think the exception should be caught and handled as this is an implicit listener the library sets (not requested by the developer). But it might be a design decision to "silently" let it fail (though I would argue it would be better to catch and not re-raise instead).

More of a dev experience bug I would say, not sure if it's user impacting as well. Thoughts?

System information

  • OS: macOS
  • Version of supabase-py: 2.15.2, server
  • Version of Python: 3.12

Metadata

Metadata

Assignees

No one assigned

    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