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

PostgrestErrors not reported correctly #39

Open
leoMehlig opened this issue Mar 29, 2023 · 1 comment · May be fixed by #43
Open

PostgrestErrors not reported correctly #39

leoMehlig opened this issue Mar 29, 2023 · 1 comment · May be fixed by #43
Labels
bug Something isn't working

Comments

@leoMehlig
Copy link

Bug report

Describe the bug

I noticed that I never see the actual error that Postgrest returns, but instead get a generic statusCode: 400 error. I had to set breakpoints and print the response to see what was actually wrong.

After some digging through the code, I noticed that the problem is that the validateResponse delegate method from APIClientDelegate is never called on PostgrestAPIClientDelegate. This is because the supabase-swift package adds its own delegate, resulting in a MultiAPIClientDelegate being set.

So far so good, but since supbase-swift does not implement validateResponse the default implementation from the Get package gets called, which throws this generic error and the custom implementation from PostgrestAPIClientDelegate never gets called.

The easy way to fix this, is to give PostgrestAPIClientDelegate precedence to whatever delegate is passed to PostgrestClient.init, but I could imagine this having other unforeseen consequences.

The change would simply be to change the line 32 in PostgrestClient.swift from this:

$0.delegate = MultiAPIClientDelegate([customDelegate, PostgrestAPIClientDelegate()])

to this:

$0.delegate = MultiAPIClientDelegate([PostgrestAPIClientDelegate(), customDelegate])

Alternatively, the SupabaseClient could implement the validateResponse method and just not do any validation.

What do you think? I'm happy to submit a PR, but don't feel either approach is perfect.

@leoMehlig leoMehlig added the bug Something isn't working label Mar 29, 2023
@grdsdev
Copy link
Contributor

grdsdev commented Jul 12, 2023

Hey @leoMehlig thanks for opening this.

I'm currently working on the removal of the Get library as a dependency on #43, this issue will be fixed.

@grdsdev grdsdev linked a pull request Jul 12, 2023 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