You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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 fromAPIClientDelegate
is never called onPostgrestAPIClientDelegate
. This is because thesupabase-swift
package adds its own delegate, resulting in aMultiAPIClientDelegate
being set.So far so good, but since
supbase-swift
does not implementvalidateResponse
the default implementation from theGet
package gets called, which throws this generic error and the custom implementation fromPostgrestAPIClientDelegate
never gets called.The easy way to fix this, is to give
PostgrestAPIClientDelegate
precedence to whatever delegate is passed toPostgrestClient.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 thevalidateResponse
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.
The text was updated successfully, but these errors were encountered: