firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.72k stars 3.97k forks source link

[firebase_auth] : Error message isn't clear if any field is passed and `null` value and app throws `"Unhandled Exception: [firebase_auth/unknown] null"` #7233

Closed muddi900 closed 2 years ago

muddi900 commented 3 years ago

Bug report

Describe the bugT The firebase app is being initialized in the main. The code worked as of last week. The error is thrown at sign-up or login. The error persists on multiple dev environment and test devices. The issue happens on the Emulator and the Live settings. I do not know what changed.

Steps to reproduce

Just try logging in.

Expected behavior

The app should log in or through a non-null error.

Sample project

My main()

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();

  if (IS_EMULATOR) {
    if (!kIsWeb) {
      String host = !Platform.isAndroid ? 'localhost' : '10.0.2.2';
      await FirebaseAuth.instance.useAuthEmulator(host, 9099);
      FirebaseFirestore.instance.settings = Settings(
        host: '$host:8080',
        sslEnabled: false,
        persistenceEnabled: false,
      );
      await fbStorage.FirebaseStorage.instance.useStorageEmulator(host, 9199);
      if (Platform.isIOS) timeDilation = 2.0;
    } else {
      await FirebaseAuth.instance.useAuthEmulator('localhost', 9099);
      FirebaseFirestore.instance.useFirestoreEmulator('localhost', 8080);
      await fbStorage.FirebaseStorage.instance
          .useStorageEmulator('localhost', 9199);
    }
  }

  runApp(const MyApp());
}

My auth function:

void _submitLogin(String email, String password) async {
      final _auth = FirebaseAuth.instance;
      UserCredential user;
      final firestore = FirebaseFirestore.instance;
      bool haveDaysSelected = !_daysOfWeek.values.every((element) => !element);
      bool haveImage = _profileImage != null;
      bool haveCourts = _tennisCourts.isNotEmpty;

      if (_isSignup) {
        user = await _auth.createUserWithEmailAndPassword(
          email: email,
          password: password,
        );

       /*unrelated Firestore logic*/

        return;
      }

await _auth.signInWithEmailAndPassword(email: email, password: password);

Additional context

Add any other context about the problem here.


Flutter doctor

Click To Expand ``` [√] Flutter (Channel stable, 2.5.1, on Microsoft Windows [Version 10.0.19043.1288], locale en-US) • Flutter version 2.5.1 at C:\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision ffb2ecea52 (5 weeks ago), 2021-09-17 15:26:33 -0400 • Engine revision b3af521a05 • Dart version 2.14.2 [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at C:\Users\muddi\AppData\Local\Android\sdk • Platform android-30, build-tools 30.0.2 • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe [√] Android Studio (version 2020.3) • Android Studio at C:\Program Files\Android\Android Studio1 • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) [√] VS Code (version 1.61.2) • VS Code at C:\Users\muddi\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.27.0 [√] Connected device (3 available) • AOSP on IA Emulator (mobile) • emulator-5554 • android-x86 • Android 9 (API 28) (emulator) • Chrome (web) • chrome • web-javascript • Google Chrome 95.0.4638.54 • Edge (web) • edge • web-javascript • Microsoft Edge 94.0.992.50 ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` Dart SDK 2.14.2 Flutter SDK 2.5.1 tennis_tennis_love 1.0.0+1 dependencies: - cached_network_image 3.1.0 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web] - cloud_firestore 2.3.0 [cloud_firestore_platform_interface cloud_firestore_web firebase_core firebase_core_platform_interface flutter meta] - crop_image 1.0.1 [flutter meta] - cross_file_image 0.0.1 [cross_file flutter] - cupertino_icons 1.0.3 - firebase_auth 2.0.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 1.4.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_storage 10.0.0 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_html 2.1.2 [html csslib flutter_layout_grid video_player chewie webview_flutter chewie_audio flutter_svg flutter_math_fork collection numerus flutter] - flutter_stripe 1.3.0 [flutter stripe_android stripe_ios stripe_platform_interface] - geolocator 7.6.2 [flutter geolocator_platform_interface geolocator_android geolocator_apple geolocator_web] - http 0.13.3 [async http_parser meta path pedantic] - image_picker 0.8.4+2 [flutter flutter_plugin_android_lifecycle image_picker_for_web image_picker_platform_interface] - location 4.3.0 [flutter location_platform_interface location_web] - mapbox_api 1.0.0 [http] - modal_bottom_sheet 2.0.0 [flutter] - multiple_stream_builder 2.0.0 [flutter tuple] - path_provider 2.0.5 [flutter path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows] - provider 6.0.0 [collection flutter nested] - universal_html 2.0.8 [async csslib charcode collection html meta source_span typed_data universal_io] - universal_io 2.0.4 [collection crypto meta typed_data] - url_launcher 6.0.6 [flutter meta url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - validators 3.0.0 - webview_flutter 2.0.8 [flutter] dev dependencies: - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data] transitive dependencies: - async 2.8.1 [collection meta] - boolean_selector 2.1.0 [source_span string_scanner] - cached_network_image_platform_interface 1.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.0.0 [flutter flutter_cache_manager cached_network_image_platform_interface] - characters 1.1.0 - charcode 1.3.1 - chewie 1.1.0 [cupertino_icons flutter video_player wakelock] - chewie_audio 1.2.0 [cupertino_icons flutter video_player] - clock 1.1.0 - cloud_firestore_platform_interface 5.2.0 [collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 2.2.0 [cloud_firestore_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - collection 1.15.0 - cross_file 0.3.1+4 [flutter meta] - crypto 3.0.1 [collection typed_data] - csslib 0.17.0 [source_span] - fake_async 1.2.0 [clock collection] - ffi 1.1.2 - file 6.1.2 [meta path] - firebase_auth_platform_interface 5.0.0 [firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 2.0.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_storage_platform_interface 4.0.0 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.0.0 [async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - flutter_blurhash 0.6.0 [flutter meta pedantic] - flutter_cache_manager 3.1.2 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid] - flutter_layout_grid 1.0.3 [flutter collection meta quiver] - flutter_math_fork 0.4.1 [flutter flutter_svg provider meta collection tuple] - flutter_plugin_android_lifecycle 2.0.2 [flutter] - flutter_svg 0.22.0 [flutter meta path_drawing vector_math xml] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - freezed_annotation 0.14.3 [collection json_annotation meta] - geolocator_android 1.0.2 [flutter geolocator_platform_interface] - geolocator_apple 1.2.0 [flutter geolocator_platform_interface] - geolocator_platform_interface 2.3.5 [flutter plugin_platform_interface vector_math meta] - geolocator_web 2.0.6 [flutter flutter_web_plugins geolocator_platform_interface] - html 0.15.0 [csslib source_span] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - image_picker_for_web 2.1.0 [flutter flutter_web_plugins image_picker_platform_interface meta] - image_picker_platform_interface 2.4.1 [flutter http meta plugin_platform_interface cross_file] - intl 0.17.0 [clock path] - js 0.6.3 - json_annotation 4.1.0 [meta] - location_platform_interface 2.3.0 [flutter meta plugin_platform_interface] - location_web 3.1.1 [flutter flutter_web_plugins http_parser js location_platform_interface meta] - matcher 0.12.10 [stack_trace] - meta 1.7.0 - nested 1.0.0 [flutter] - numerus 1.1.1 - octo_image 1.0.0+1 [flutter flutter_blurhash] - path 1.8.0 - path_drawing 0.5.1 [vector_math meta path_parsing flutter] - path_parsing 0.2.1 [vector_math meta] - path_provider_linux 2.0.2 [flutter path path_provider_platform_interface xdg_directories] - path_provider_macos 2.0.2 [flutter] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.3 [ffi flutter meta path path_provider_platform_interface win32] - pedantic 1.11.1 - petitparser 4.3.0 [meta] - platform 3.0.0 - plugin_platform_interface 2.0.0 [meta] - process 4.2.3 [file path platform] - quiver 3.0.1 [matcher] - rxdart 0.27.1 - sky_engine 0.0.99 - source_span 1.8.1 [collection path term_glyph] - sqflite 2.0.0+3 [flutter sqflite_common path] - sqflite_common 2.0.0+2 [synchronized path meta] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - string_scanner 1.1.0 [charcode source_span] - stripe_android 1.3.0 [flutter] - stripe_ios 1.3.0 [flutter] - stripe_platform_interface 1.3.0 [flutter freezed_annotation json_annotation meta plugin_platform_interface] - synchronized 3.0.0 - term_glyph 1.2.0 - test_api 0.4.2 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - tuple 2.0.0 [quiver] - typed_data 1.3.0 [collection] - url_launcher_linux 2.0.0 [flutter] - url_launcher_macos 2.0.0 [flutter] - url_launcher_platform_interface 2.0.3 [flutter plugin_platform_interface] - url_launcher_web 2.0.1 [flutter flutter_web_plugins meta url_launcher_platform_interface] - url_launcher_windows 2.0.0 [flutter] - uuid 3.0.4 [crypto] - vector_math 2.1.0 - video_player 2.2.5 [flutter meta video_player_platform_interface video_player_web html] - video_player_platform_interface 4.2.0 [flutter flutter_test meta] - video_player_web 2.0.4 [flutter flutter_web_plugins meta video_player_platform_interface] - wakelock 0.5.6 [flutter meta wakelock_macos wakelock_platform_interface wakelock_web wakelock_windows] - wakelock_macos 0.4.0 [flutter flutter_web_plugins wakelock_platform_interface] - wakelock_platform_interface 0.3.0 [flutter meta] - wakelock_web 0.4.0 [flutter flutter_web_plugins js wakelock_platform_interface] - wakelock_windows 0.2.0 [flutter wakelock_platform_interface win32] - win32 2.0.5 [ffi] - xdg_directories 0.2.0 [meta path process] - xml 5.3.0 [collection meta petitparser] ```

Puspharaj commented 3 years ago

I have uploaded an internal testing app to playstore. Installed in my local phone through playstore to test it out seems not working anymore with firebase google_sign_in. Waiting for the app to finish Pre-launch report to see how it works. But for sure something not right. My local dev version apps works fine on android, web.

muddi900 commented 3 years ago

The issue persists when firebase_core is updated the latest version(1.8.0)

darshankawar commented 3 years ago

@muddi900 You seem to be on a bit older version of the framework and auth plugin. Please upgrade them to latest and try again. Also, if issue persists, provide full verbose log containing the error.

muddi900 commented 3 years ago

@darshankawar The issue persists even after updating all firebase plugins.

Dependencies

Click to Expand ``` Dart SDK 2.14.2 Flutter SDK 2.5.1 tennis_tennis_love 1.0.0+1 dependencies: - cached_network_image 3.1.0 [flutter flutter_cache_manager octo_image cached_network_image_platform_interface cached_network_image_web] - cloud_firestore 2.5.4 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - crop_image 1.0.1 [flutter meta] - cross_file_image 0.0.1 [cross_file flutter] - cupertino_icons 1.0.3 - firebase_auth 2.0.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 1.8.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_storage 10.0.6 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_html 2.1.2 [html csslib flutter_layout_grid video_player chewie webview_flutter chewie_audio flutter_svg flutter_math_fork collection numerus flutter] - flutter_stripe 1.3.0 [flutter stripe_android stripe_ios stripe_platform_interface] - http 0.13.3 [async http_parser meta path pedantic] - image_picker 0.8.4+2 [flutter flutter_plugin_android_lifecycle image_picker_for_web image_picker_platform_interface] - location 4.3.0 [flutter location_platform_interface location_web] - mapbox_api 1.0.0 [http] - modal_bottom_sheet 2.0.0 [flutter] - multiple_stream_builder 2.0.0 [flutter tuple] - path_provider 2.0.5 [flutter path_provider_linux path_provider_macos path_provider_platform_interface path_provider_windows] - provider 6.0.0 [collection flutter nested] - universal_html 2.0.8 [async csslib charcode collection html meta source_span typed_data universal_io] - universal_io 2.0.4 [collection crypto meta typed_data] - url_launcher 6.0.6 [flutter meta url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - validators 3.0.0 - webview_flutter 2.0.8 [flutter] dev dependencies: - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data] transitive dependencies: - async 2.8.1 [collection meta] - boolean_selector 2.1.0 [source_span string_scanner] - cached_network_image_platform_interface 1.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.0.0 [flutter flutter_cache_manager cached_network_image_platform_interface] - characters 1.1.0 - charcode 1.3.1 - chewie 1.1.0 [cupertino_icons flutter video_player wakelock] - chewie_audio 1.2.0 [cupertino_icons flutter video_player] - clock 1.1.0 - cloud_firestore_platform_interface 5.4.3 [collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 2.4.4 [cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - collection 1.15.0 - cross_file 0.3.1+4 [flutter meta] - crypto 3.0.1 [collection typed_data] - csslib 0.17.0 [source_span] - fake_async 1.2.0 [clock collection] - ffi 1.1.2 - file 6.1.2 [meta path] - firebase_auth_platform_interface 5.0.0 [firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 2.0.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.0.1 [collection flutter meta plugin_platform_interface] - firebase_core_web 1.1.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_storage_platform_interface 4.0.4 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.0.4 [async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - flutter_blurhash 0.6.0 [flutter meta pedantic] - flutter_cache_manager 3.1.2 [clock collection file flutter http path path_provider pedantic rxdart sqflite uuid] - flutter_layout_grid 1.0.3 [flutter collection meta quiver] - flutter_math_fork 0.4.1 [flutter flutter_svg provider meta collection tuple] - flutter_plugin_android_lifecycle 2.0.2 [flutter] - flutter_svg 0.22.0 [flutter meta path_drawing vector_math xml] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - freezed_annotation 0.14.3 [collection json_annotation meta] - html 0.15.0 [csslib source_span] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - image_picker_for_web 2.1.0 [flutter flutter_web_plugins image_picker_platform_interface meta] - image_picker_platform_interface 2.4.1 [flutter http meta plugin_platform_interface cross_file] - intl 0.17.0 [clock path] - js 0.6.3 - json_annotation 4.1.0 [meta] - location_platform_interface 2.3.0 [flutter meta plugin_platform_interface] - location_web 3.1.1 [flutter flutter_web_plugins http_parser js location_platform_interface meta] - matcher 0.12.10 [stack_trace] - meta 1.7.0 - nested 1.0.0 [flutter] - numerus 1.1.1 - octo_image 1.0.0+1 [flutter flutter_blurhash] - path 1.8.0 - path_drawing 0.5.1 [vector_math meta path_parsing flutter] - path_parsing 0.2.1 [vector_math meta] - path_provider_linux 2.0.2 [flutter path path_provider_platform_interface xdg_directories] - path_provider_macos 2.0.2 [flutter] - path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface] - path_provider_windows 2.0.3 [ffi flutter meta path path_provider_platform_interface win32] - pedantic 1.11.1 - petitparser 4.3.0 [meta] - platform 3.0.0 - plugin_platform_interface 2.0.0 [meta] - process 4.2.3 [file path platform] - quiver 3.0.1 [matcher] - rxdart 0.27.1 - sky_engine 0.0.99 - source_span 1.8.1 [collection path term_glyph] - sqflite 2.0.0+3 [flutter sqflite_common path] - sqflite_common 2.0.0+2 [synchronized path meta] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - string_scanner 1.1.0 [charcode source_span] - stripe_android 1.3.0 [flutter] - stripe_ios 1.3.0 [flutter] - stripe_platform_interface 1.3.0 [flutter freezed_annotation json_annotation meta plugin_platform_interface] - synchronized 3.0.0 - term_glyph 1.2.0 - test_api 0.4.2 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - tuple 2.0.0 [quiver] - typed_data 1.3.0 [collection] - url_launcher_linux 2.0.0 [flutter] - url_launcher_macos 2.0.0 [flutter] - url_launcher_platform_interface 2.0.3 [flutter plugin_platform_interface] - url_launcher_web 2.0.1 [flutter flutter_web_plugins meta url_launcher_platform_interface] - url_launcher_windows 2.0.0 [flutter] - uuid 3.0.4 [crypto] - vector_math 2.1.0 - video_player 2.2.5 [flutter meta video_player_platform_interface video_player_web html] - video_player_platform_interface 4.2.0 [flutter flutter_test meta] - video_player_web 2.0.4 [flutter flutter_web_plugins meta video_player_platform_interface] - wakelock 0.5.6 [flutter meta wakelock_macos wakelock_platform_interface wakelock_web wakelock_windows] - wakelock_macos 0.4.0 [flutter flutter_web_plugins wakelock_platform_interface] - wakelock_platform_interface 0.3.0 [flutter meta] - wakelock_web 0.4.0 [flutter flutter_web_plugins js wakelock_platform_interface] - wakelock_windows 0.2.0 [flutter wakelock_platform_interface win32] - win32 2.0.5 [ffi] - xdg_directories 0.2.0 [meta path process] - xml 5.3.0 [collection meta petitparser] ```
darshankawar commented 3 years ago

@muddi900 Can you provide the complete verbose log that shows the exception ? Thanks.

muddi900 commented 3 years ago
E/flutter (10993): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: [firebase_auth/unknown] null
E/flutter (10993): #0      MethodChannelFirebaseAuth.signInWithEmailAndPassword
package:firebase_auth_platform_interface/…/method_channel/method_channel_firebase_auth.dart:489
E/flutter (10993): <asynchronous suspension>
E/flutter (10993): #1      FirebaseAuth.signInWithEmailAndPassword
package:firebase_auth/src/firebase_auth.dart:508
E/flutter (10993): <asynchronous suspension>
E/flutter (10993): #2      LoginScreenState.build._submitLogin
package:tennis_tennis_love/screens/login_screen.dart:364
E/flutter (10993): <asynchronous suspension>
darshankawar commented 3 years ago

@muddi900 Do you get this error while running on a physical device too ? or just an emulator or firebase emulator only ? I just tried with official plugin example with which I was able to authenticate and run properly. Can you try the same and see if you still get same behavior ?

muddi900 commented 3 years ago

The error was due to me passing through a null value to the password field. So the bug is in the error message. If the error message was more clear, it would have been a lot of time.

darshankawar commented 3 years ago

Thanks for identifying root-cause. Can you provide a code snippet for passing through a null value to the password field that we can take a look at and verify ? Does it only happen for password field or for any field ?

muddi900 commented 3 years ago

I was just passing a null value to the log- call back.

On Thu, Oct 28, 2021 at 4:40 AM darshankawar @.***> wrote:

Thanks for identifying root-cause. Can you provide a code snippet for passing through a null value to the password field that we can take a look at and verify ? Does it only happen for password field or for any field ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/FirebaseExtended/flutterfire/issues/7233#issuecomment-953682362, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI2VVZSJMOJR4R4S66YP5W3UJELBNANCNFSM5GS6IH4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

darshankawar commented 3 years ago

Keeping it open and labeling for team's radar.

russellwheatley commented 2 years ago

This is a required field. See here. You cannot pass null as a password.

muddi900 commented 2 years ago

While the solution is provided for the root cause, it would be impossible to guess just by reading the error message. The exception should make it clear that the Password field is null.

The issue might be the code, but it would require a lot of work just to figure it out.