supabase / supabase-flutter

Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.
https://supabase.com/
MIT License
661 stars 154 forks source link

auth: `updateUser` throws TypeError when new password is too short #891

Closed devj3ns closed 2 months ago

devj3ns commented 2 months ago

Describe the bug When using the updateUser function to update the users password and providing a too short password, the function throws the following exception:

TypeError: Instance of 'JSArray<dynamic>': type 'List<dynamic>' is not a subtype of type 'List<String>'

To Reproduce Run the following example code when being logged in with the minimum password setting in the Supabase Dashboard set to a value >3:

final supabase = Supabase.instance.client;
await supabase.auth.updateUser(auth.UserAttributes(password: "123"));

Expected behavior I would expect the function to throw the AuthWeakPasswordException

Version: Happens on Android and the Web. Flutter Version: 3.19.5

????????? supabase_flutter 2.5.1 ??? ????????? supabase 2.1.1 ??? ??? ????????? functions_client 2.0.0 ??? ??? ????????? gotrue 2.6.0 ??? ??? ????????? postgrest 2.1.1 ??? ??? ????????? realtime_client 2.0.4 ??? ??? ????????? storage_client 2.0.1

Additional context I debugged the supbase_flutter code a bit and to me, it looks like the problem is inside the GotrueFetch _handleError function: https://github.com/supabase/supabase-flutter/blob/c4e73c7621456af556812e4a9823ecd8ea3bc81a/packages/gotrue/lib/src/fetch.dart#L50

I assume the issue is introduced with https://github.com/supabase/supabase-flutter/pull/879