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

🐛 [firebase_auth] verifyBeforeUpdateEmail causes exception on Firebase Emulator #5244

Closed
kaboc opened this issue Mar 6, 2021 · 6 comments
Labels
blocked: firebase-sdk plugin: auth resolution: invalid This doesn't seem right and might not belong here. type: bug Something isn't working

Comments

@kaboc
Copy link

kaboc commented Mar 6, 2021

Bug report

The following error message is shown in the console of IDE when verifyBeforeUpdateEmail() is used with the Firebase Auth emulator.

E/flutter (17362): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: [firebase_auth/unknown] com.google.firebase.FirebaseException: An internal error has occurred. [ VERIFY_AND_CHANGE_EMAIL ]
E/flutter (17362): #0      MethodChannelUser.verifyBeforeUpdateEmail (package:firebase_auth_platform_interface/src/method_channel/method_channel_user.dart:274:7)
E/flutter (17362): <asynchronous suspension>
E/flutter (17362): #1      User.verifyBeforeUpdateEmail (package:firebase_auth/src/user.dart:352:5)
E/flutter (17362): <asynchronous suspension>

Steps to reproduce

Steps to reproduce the behavior:

  1. Write some code to use verifyBeforeUpdateEmail()
  2. Run the app and do some action to use the method
  3. See the output in the console

Expected behavior

I'm not really sure what should happen with the auth emulator, but guessing from sendEmailVerification() that is similar to verifyBeforeUpdateEmail(), a verification URL should probably be shown in the console running the emulator.


Additional context

I experienced this with Flutter 1.22.6 & firebase_auth 0.20.1, and it was reproduced in Flutter 2.0.1 & firebase_auth 1.0.0.
The exception only occurs with the emulator. With the cloud backend, a verification email arrives in my inbox.

The project itself has not been migrated to null safety, but most dependencies are up-to-date. (Code generation outputs a lot of errors, so freezed and json_serializable have been kept outdated.)


Flutter doctor

Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.1, on Microsoft Windows [Version 10.0.19042.804], locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Chrome - develop for the web
[✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.4)
[✓] Android Studio (version 4.1.0)
[✓] VS Code, 64-bit edition (version 1.53.2)
[✓] Connected device (4 available)

• No issues found!

Flutter dependencies

Click To Expand
Dart SDK 2.12.0
Flutter SDK 2.0.1
xxxx 1.0.0+1

dependencies:
- async 2.5.0 [collection]
- cloud_firestore 1.0.0 [cloud_firestore_platform_interface cloud_firestore_web firebase_core firebase_core_platform_interface flutter meta]
- custom_text 0.1.0 [flutter text_parser]
- firebase_analytics 7.1.0 [meta flutter firebase_core firebase_analytics_web firebase_analytics_platform_interface]
- firebase_auth 1.0.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_crashlytics 1.0.0 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_localizations 0.0.0 [flutter intl characters clock collection meta path typed_data vector_math]
- flutter_state_notifier 0.7.0 [flutter meta provider state_notifier]
- get_it 6.0.0 [async collection]
- google_fonts 2.0.0 [flutter http path_provider crypto]
- intl 0.17.0 [clock path]
- logger 0.9.4
- shared_preferences 2.0.3 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows]
- url_launcher 5.7.10 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]

dev dependencies:
- build_runner 1.11.5 [args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style glob graphs http_multi_server io js logging meta mime path pedantic pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml]
- flutter_driver 0.0.0 [file meta path vm_service webdriver flutter flutter_test fuchsia_remote_debug_protocol archive args async boolean_selector characters charcode clock collection convert crypto fake_async matcher platform process source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math]
- freezed 0.12.7 [analyzer build build_config meta source_gen freezed_annotation]
- grinder 0.8.6 [cli_util glob meta path]
- json_serializable 3.5.1 [analyzer build build_config json_annotation meta path source_gen]
- test 1.16.5 [analyzer async boolean_selector coverage http_multi_server io js node_preamble package_config path pedantic pool shelf shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace stream_channel typed_data web_socket_channel webkit_inspection_protocol yaml test_api test_core]

dependency overrides:
- crypto 3.0.0 [collection typed_data]
- glob 2.0.0 [async collection file path pedantic string_scanner]
- http 0.13.0 [http_parser meta path pedantic]
- http_parser 4.0.0 [charcode collection source_span string_scanner typed_data]
- plugin_platform_interface 2.0.0 [meta]

transitive dependencies:
- _fe_analyzer_shared 14.0.0 [meta]
- analyzer 0.41.2 [_fe_analyzer_shared args cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml]
- archive 2.0.13 [crypto args path]
- args 1.6.0
- boolean_selector 2.1.0 [source_span string_scanner]
- build 1.6.2 [analyzer async convert crypto glob logging meta path]
- build_config 0.4.6 [checked_yaml json_annotation meta path pubspec_parse yaml]
- build_daemon 2.1.8 [built_collection built_value http_multi_server logging pedantic path pool shelf shelf_web_socket stream_transform watcher web_socket_channel]
- build_resolvers 1.5.3 [analyzer build crypto graphs logging meta path package_config pool pub_semver]
- build_runner_core 6.1.10 [async build build_config build_resolvers collection convert crypto glob graphs logging meta path package_config pedantic pool timing watcher yaml]
- built_collection 5.0.0
- built_value 8.0.0 [built_collection collection fixnum]
- characters 1.1.0
- charcode 1.2.0
- checked_yaml 1.0.4 [json_annotation source_span yaml]
- cli_util 0.3.0 [meta path]
- clock 1.1.0
- cloud_firestore_platform_interface 4.0.0 [collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 1.0.0 [cloud_firestore_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js]
- code_builder 3.6.0 [built_collection built_value collection matcher meta]
- collection 1.15.0
- convert 2.1.1 [charcode typed_data]
- coverage 0.15.2 [args logging package_config path source_maps stack_trace vm_service]
- dart_style 1.3.12 [analyzer args path pub_semver source_span]
- fake_async 1.2.0 [clock collection]
- ffi 1.0.0
- file 6.0.0 [meta path]
- firebase 7.3.3 [http http_parser js]
- firebase_analytics_platform_interface 1.1.0 [flutter meta]
- firebase_analytics_web 0.2.0 [flutter flutter_web_plugins firebase firebase_analytics_platform_interface meta]
- firebase_auth_platform_interface 4.0.0 [firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 1.0.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta]
- firebase_core 1.0.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_core_platform_interface 4.0.0 [flutter meta plugin_platform_interface]
- firebase_core_web 1.0.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_crashlytics_platform_interface 2.0.0 [collection firebase_core flutter meta plugin_platform_interface]
- fixnum 1.0.0
- 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]
- flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math]
- freezed_annotation 0.12.0 [collection json_annotation meta]
- fuchsia_remote_debug_protocol 0.0.0 [process vm_service file meta path platform]
- graphs 0.2.0
- http_multi_server 2.2.0 [async]
- io 0.3.5 [meta path string_scanner]
- js 0.6.3
- json_annotation 3.1.1
- logging 1.0.0
- matcher 0.12.10 [stack_trace]
- meta 1.3.0
- mime 1.0.0
- nested 1.0.0 [flutter]
- node_preamble 1.4.13
- package_config 1.9.3 [path charcode]
- path 1.8.0
- path_provider 2.0.1 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- path_provider_linux 2.0.0 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 2.0.0 [flutter]
- path_provider_platform_interface 2.0.1 [flutter meta platform plugin_platform_interface]
- path_provider_windows 2.0.0 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.11.0
- platform 3.0.0
- pool 1.5.0 [async stack_trace]
- process 4.0.0 [file path platform]
- provider 5.0.0-nullsafety.5 [collection flutter nested]
- pub_semver 2.0.0 [collection]
- pubspec_parse 0.1.8 [checked_yaml json_annotation pub_semver yaml]
- shared_preferences_linux 2.0.0 [flutter file meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 2.0.0 [shared_preferences_platform_interface flutter]
- shared_preferences_platform_interface 2.0.0 [flutter]
- shared_preferences_web 2.0.0 [shared_preferences_platform_interface flutter flutter_web_plugins meta]
- shared_preferences_windows 2.0.0 [shared_preferences_platform_interface flutter file meta path path_provider_platform_interface path_provider_windows]
- shelf 1.0.0 [async collection http_parser path stack_trace stream_channel]
- shelf_packages_handler 2.0.1 [path shelf shelf_static]
- shelf_static 0.2.9+2 [convert http_parser mime path shelf]
- shelf_web_socket 0.2.4+1 [shelf stream_channel web_socket_channel]
- sky_engine 0.0.99
- source_gen 0.9.10+3 [analyzer async build dart_style glob meta path pedantic source_span]
- source_map_stack_trace 2.1.0 [path stack_trace source_maps]
- source_maps 0.10.10 [source_span]
- source_span 1.8.0 [charcode collection path term_glyph]
- stack_trace 1.10.0 [path]
- state_notifier 0.7.0 [meta]
- stream_channel 2.1.0 [async]
- stream_transform 2.0.0
- string_scanner 1.1.0 [charcode source_span]
- sync_http 0.2.0
- term_glyph 1.2.0
- test_api 0.2.19 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- test_core 0.3.15 [analyzer async args boolean_selector collection coverage glob io meta package_config path pedantic pool source_map_stack_trace source_maps source_span stack_trace stream_channel vm_service yaml matcher test_api]
- text_parser 0.1.2 [meta]
- timing 0.1.1+3 [json_annotation]
- typed_data 1.3.0 [collection]
- url_launcher_linux 0.0.1+4 [flutter]
- url_launcher_macos 0.0.1+9 [flutter]
- url_launcher_platform_interface 1.0.9 [flutter meta plugin_platform_interface]
- url_launcher_web 0.1.5+3 [url_launcher_platform_interface flutter flutter_web_plugins meta]
- url_launcher_windows 0.0.1+3 [flutter]
- vector_math 2.1.0
- vm_service 5.5.0 [meta]
- watcher 1.0.0 [async path pedantic]
- web_socket_channel 1.2.0 [async crypto stream_channel]
- webdriver 2.1.2 [archive matcher path stack_trace sync_http]
- webkit_inspection_protocol 1.0.0 [logging]
- win32 2.0.0 [ffi]
- xdg_directories 0.2.0 [meta path process]
- yaml 3.1.0 [collection source_span string_scanner]

@kaboc kaboc added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Mar 6, 2021
@markusaksli-nc
Copy link
Contributor

Hi @kaboc
Have you used the specific URL meant for this?

For testing email verification/sign-in with email link flows, the emulator prints a URL to the terminal at which firebase emulators:start was executed.

(from https://firebase.google.com/docs/emulator-suite/connect_auth#emulated_email_email_link_and_anonymous_authentication)
Thank you

@markusaksli-nc markusaksli-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Mar 8, 2021
@kaboc
Copy link
Author

kaboc commented Mar 8, 2021

@markusaksli-nc
Hi! sendEmailVerification() prints a URL to the terminal but verifyBeforeUpdateEmail() does not.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Mar 8, 2021
@markusaksli-nc
Copy link
Contributor

markusaksli-nc commented Mar 9, 2021

Oh sorry I misread the issue somehow. I'm seeing this as well. sendEmailVerification prints the URL to the emulator terminal but verifyBeforeUpdateEmail throws the mentioned exception using firebase_auth: ^1.0.0 and Firebase CLI tool 9.6.0 from npm on the latest master 2.1.0-11.0.pre.165.

E/flutter (10921): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: [firebase_auth/unknown] com.google.firebase.FirebaseException: An internal error has occurred. [ VERIFY_AND_CHANGE_EMAIL ]
E/flutter (10921): #0      MethodChannelUser.verifyBeforeUpdateEmail (package:firebase_auth_platform_interface/src/method_channel/method_channel_user.dart:274:7)
E/flutter (10921): <asynchronous suspension>
E/flutter (10921): #1      User.verifyBeforeUpdateEmail (package:firebase_auth/src/user.dart:352:5)
E/flutter (10921): <asynchronous suspension>
E/flutter (10921):

flutter doctor -v
[√] Flutter (Channel master, 2.1.0-11.0.pre.165, on Microsoft Windows [Version 10.0.19041.804], locale et-EE)
    • Flutter version 2.1.0-11.0.pre.165 at C:\Development\flutter_master
    • Framework revision 698d438960 (5 hours ago), 2021-03-09 07:53:21 +0100
    • Engine revision 2441c476a6
    • Dart version 2.13.0 (build 2.13.0-116.0.dev)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\marku\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.7042882\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.7)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.7.30621.155
    • Windows 10 SDK version 10.0.18362.0

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.7042882
    • Flutter plugin version 54.0.1
    • Dart plugin version 201.9335
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] IntelliJ IDEA Ultimate Edition (version 2020.3)
    • IntelliJ at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\203.7148.57
    • 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

[√] Connected device (5 available)
    • SM G950F (mobile)           • ce12171c51cc001c03 • android-arm64  • Android 9 (API 28)
    • sdk gphone x86 arm (mobile) • emulator-5554      • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)           • windows            • windows-x64    • Microsoft Windows [Version 10.0.19041.804]
    • Chrome (web)                • chrome             • web-javascript • Google Chrome 88.0.4324.190
    • Edge (web)                  • edge               • web-javascript • Microsoft Edge 89.0.774.45

• No issues found!

CC @mikehardy although maybe this shouldn't work? The documentation doesn't explicitly mention changing email being supported with the same method.

@markusaksli-nc markusaksli-nc added plugin: auth and removed Needs Attention This issue needs maintainer attention. labels Mar 9, 2021
@mikehardy
Copy link
Contributor

I regret not being able to chase this more, but as these features should be identical (essentially) between react-native-firebase and flutterfire, I can refer to how we exercise the APIs in react-native-firebase during E2E testing (which is done against the auth emulator in react-native-firebase, but not in flutterfire yet)

mike@isabela:~/work/Invertase/react-native-firebase/packages/auth/e2e (master) % grep -rn sendEmailVerification
user.e2e.js:183:  describe('sendEmailVerification()', function () {
user.e2e.js:189:        firebase.auth().currentUser.sendEmailVerification({});
user.e2e.js:202:        firebase.auth().currentUser.sendEmailVerification({ url: 123 });
user.e2e.js:217:          .currentUser.sendEmailVerification({ url: 'string', dynamicLinkDomain: 123 });
user.e2e.js:232:        firebase.auth().currentUser.sendEmailVerification({ url: 'string', handleCodeInApp: 123 });
user.e2e.js:247:        firebase.auth().currentUser.sendEmailVerification({ url: 'string', iOS: 123 });
user.e2e.js:262:          .currentUser.sendEmailVerification({ url: 'string', iOS: { bundleId: 123 } });
user.e2e.js:277:        firebase.auth().currentUser.sendEmailVerification({ url: 'string', android: 123 });
user.e2e.js:292:          .currentUser.sendEmailVerification({ url: 'string', android: { packageName: 123 } });
user.e2e.js:307:        firebase.auth().currentUser.sendEmailVerification({
user.e2e.js:325:        firebase.auth().currentUser.sendEmailVerification({
user.e2e.js:344:        await firebase.auth().currentUser.sendEmailVerification();
user.e2e.js:346:        return Promise.reject(new Error('sendEmailVerification() caused an error', error));
user.e2e.js:362:        await firebase.auth().currentUser.sendEmailVerification();
user.e2e.js:369:        return Promise.reject(new Error('sendEmailVerification() caused an error', error));
user.e2e.js:387:        await firebase.auth().currentUser.sendEmailVerification(actionCodeSettings);
user.e2e.js:390:          new Error('sendEmailVerification(actionCodeSettings) error' + error.message),
user.e2e.js:405:        firebase.auth().currentUser.sendEmailVerification({ url: [] });
user.e2e.js:407:        "firebase.auth.User.sendEmailVerification(*) 'actionCodeSettings.url' expected a string value.",
mike@isabela:~/work/Invertase/react-native-firebase/packages/auth/e2e (master) % grep -rn verifyBeforeUpdateEmail
user.e2e.js:412:  describe('verifyBeforeUpdateEmail()', function () {
user.e2e.js:419:        firebase.auth().currentUser.verifyBeforeUpdateEmail(123);
user.e2e.js:434:        firebase.auth().currentUser.verifyBeforeUpdateEmail(updateEmail, {});
user.e2e.js:450:        firebase.auth().currentUser.verifyBeforeUpdateEmail(updateEmail, { url: 123 });
user.e2e.js:466:        firebase.auth().currentUser.verifyBeforeUpdateEmail(updateEmail, {
user.e2e.js:487:        firebase.auth().currentUser.verifyBeforeUpdateEmail(updateEmail, {
user.e2e.js:508:        firebase.auth().currentUser.verifyBeforeUpdateEmail(updateEmail, {
user.e2e.js:527:        firebase.auth().currentUser.verifyBeforeUpdateEmail(updateEmail, {
user.e2e.js:548:        firebase.auth().currentUser.verifyBeforeUpdateEmail(updateEmail, {
user.e2e.js:567:        firebase.auth().currentUser.verifyBeforeUpdateEmail(updateEmail, {
user.e2e.js:588:        firebase.auth().currentUser.verifyBeforeUpdateEmail(updateEmail, {
user.e2e.js:609:        firebase.auth().currentUser.verifyBeforeUpdateEmail(updateEmail, {
user.e2e.js:632:        await firebase.auth().currentUser.verifyBeforeUpdateEmail(updateEmail);
user.e2e.js:634:        return Promise.reject("'verifyBeforeUpdateEmail()' did not work");
user.e2e.js:651:        await firebase.auth().currentUser.verifyBeforeUpdateEmail(updateEmail, actionCodeSettings);
user.e2e.js:661:        return Promise.reject("'verifyBeforeUpdateEmail()' with 'actionCodeSettings' did not work");

Those are the files + line numbers into the e2e tests for the auth package so you can scan to see if your use case is being exercised by that near-identical-twin project with success or not. Could be we are missing cases in react-native-firebase though coverage is pretty thorough, definitely is the case flutterfire is not exercising itself against the emulator during E2E testing as I have not ported this file for the E2E-host-to-auth-emulator interaction yet and you need that to get the OOB codes etc during test

@russellwheatley
Copy link
Member

I've confirmed this as a problem with the auth emulator (at least it works without using the emulator). RNFB also receives the same error, the integration tests for verifyBeforeUpdateEmail are not being executed here.

I've had a comb through the android sdk for the error code but it isn't there so it must be coming from the server (emulator) itself:

android error:

[firebase_auth/unknown] com.google.firebase.FirebaseException: An internal error has occurred. [ VERIFY_AND_CHANGE_EMAIL ]

ios error:

[firebase_auth/internal-error] An internal error has occurred, print and inspect the error details for more information.

@russellwheatley
Copy link
Member

Closing as this is an auth emulator issue that should be tracked here: firebase/firebase-tools#3424

@firebase firebase locked and limited conversation to collaborators Mar 25, 2024
@TarekkMA TarekkMA added the resolution: invalid This doesn't seem right and might not belong here. label Apr 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: firebase-sdk plugin: auth resolution: invalid This doesn't seem right and might not belong here. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants