Skip to content

[firebase_auth]: Errors from 'beforeUserSignIn' type blocking functions get clobbered into [firebase_auth/unknown_error] #17592

@jordanenglish-overlay

Description

@jordanenglish-overlay

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Auth

Which platforms are affected?

Windows

Description

When signing in with email and password, my project has a 'beforeUserSignIn' blocking function running before logging in that throws an HttpsError. On android/ios/web, throwing an HttpsError within the blocking function can be detected by the client attempting login, with it able to read the contents (i.e. that the HttpsError is 'failed-precondition').

On Windows, errors from the blocking function are clobbered into 'unknown-error' and any extra data in the HttpError is inaccessible.

Login when the blocking function immediately returns without error works as intended.

Reproducing the issue

Using the example project on Windows, sign in with email and password whilst a blocking function has been configured and deployed.

You may need to configure the function in the Firebase Console at Authentication > Settings > Blocking Functions.

I was able to replicate the issue with this cloud function deployed.

min-viable-blocking.js

import { HttpsError, beforeUserSignedIn } from "firebase-functions/v2/identity";
import { setGlobalOptions } from 'firebase-functions/v2'

const functionConfig = {
    region: "asia-south1",
    concurrency: 60,
    minInstances: 0,
    maxInstances: 10,
    cpu: 1.0,
};

setGlobalOptions(functionConfig);

export const beforeSignIn = beforeUserSignedIn( (event)  => {
    throw new HttpsError(
        "failed-precondition",
        "error message for the client to read", 
        {'usefulData': 'drink some water'}
    );
});

For debugging purposes, I also edited firebase_auth/example/lib/auth.dart to catch, log and rethrow auth.SignInWithEmailAndPassword() on line 479.

Firebase Core version

4.0.0

Flutter Version

3.26.0

Relevant Log Output

[firebase_auth/unknown-error] An internal error has occurred.

Flutter dependencies

Expand Flutter dependencies snippet
Dart SDK 3.7.2
Flutter SDK 3.29.3
firebase_auth_example 0.0.0

dependencies:
- barcode_widget 2.0.4 [barcode flutter]
- firebase_auth 6.0.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 4.0.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_messaging 16.0.0 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_facebook_auth 7.1.2 [flutter flutter_facebook_auth_platform_interface flutter_facebook_auth_web facebook_auth_desktop]
- flutter_signin_button 2.0.0 [flutter font_awesome_flutter]
- google_sign_in 6.3.0 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web]
- google_sign_in_dartio 0.3.0 [flutter google_sign_in google_sign_in_platform_interface shared_preferences shared_preferences_foundation shared_preferences_linux url_launcher url_launcher_macos crypto http html_unescape]

dev dependencies:
- http 1.4.0 [async http_parser meta web]

transitive dependencies:
- _flutterfire_internals 1.3.60 [collection firebase_core firebase_core_platform_interface flutter meta]
- async 2.12.0 [collection meta]
- barcode 2.2.9 [meta qr]
- boolean_selector 2.1.2 [source_span string_scanner]
- characters 1.4.0
- clock 1.1.2
- collection 1.19.1
- crypto 3.0.6 [typed_data]
- facebook_auth_desktop 2.1.1 [flutter http flutter_secure_storage flutter_facebook_auth_platform_interface]
- fake_async 1.3.2 [clock collection]
- ffi 2.1.4
- file 7.0.1 [meta path]
- firebase_auth_platform_interface 8.0.0 [_flutterfire_internals collection firebase_core flutter http meta plugin_platform_interface]
- firebase_auth_web 6.0.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser meta web]
- firebase_core_platform_interface 6.0.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 3.0.0 [firebase_core_platform_interface flutter flutter_web_plugins meta web]
- firebase_messaging_platform_interface 4.7.0 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 4.0.0 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins meta web]
- flutter_facebook_auth_platform_interface 6.1.2 [flutter plugin_platform_interface]
- flutter_facebook_auth_web 6.1.2 [flutter flutter_web_plugins flutter_facebook_auth_platform_interface web]
- flutter_secure_storage 9.2.4 [flutter flutter_secure_storage_linux flutter_secure_storage_macos flutter_secure_storage_platform_interface flutter_secure_storage_web flutter_secure_storage_windows meta]
- flutter_secure_storage_linux 1.2.3 [flutter flutter_secure_storage_platform_interface]
- flutter_secure_storage_macos 3.1.3 [flutter flutter_secure_storage_platform_interface]
- flutter_secure_storage_platform_interface 1.1.2 [flutter plugin_platform_interface]
- flutter_secure_storage_web 1.2.1 [flutter flutter_secure_storage_platform_interface flutter_web_plugins js]
- flutter_secure_storage_windows 3.1.2 [ffi flutter flutter_secure_storage_platform_interface path path_provider win32]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math leak_tracker_flutter_testing async boolean_selector characters collection leak_tracker leak_tracker_testing material_color_utilities meta source_span stream_channel string_scanner term_glyph vm_service]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math]
- font_awesome_flutter 9.2.0 [flutter]
- google_identity_services_web 0.3.3+1 [meta web]
- google_sign_in_android 6.2.1 [flutter google_sign_in_platform_interface]
- google_sign_in_ios 5.9.0 [flutter google_sign_in_platform_interface]
- google_sign_in_platform_interface 2.5.0 [flutter plugin_platform_interface]
- google_sign_in_web 0.12.4+4 [flutter flutter_web_plugins google_identity_services_web google_sign_in_platform_interface http web]
- html_unescape 2.0.0
- http_parser 4.1.2 [collection source_span string_scanner typed_data]
- js 0.6.7 [meta]
- leak_tracker 10.0.8 [clock collection meta path vm_service]
- leak_tracker_flutter_testing 3.0.9 [flutter leak_tracker leak_tracker_testing matcher meta]
- leak_tracker_testing 3.0.1 [leak_tracker matcher meta]
- matcher 0.12.17 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.11.1 [collection]
- meta 1.16.0
- path 1.9.1
- path_provider 2.1.5 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows]
- path_provider_android 2.2.17 [flutter path_provider_platform_interface]
- path_provider_foundation 2.4.1 [flutter path_provider_platform_interface]
- path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.1.2 [flutter platform plugin_platform_interface]
- path_provider_windows 2.3.0 [ffi flutter path path_provider_platform_interface]
- platform 3.1.6
- plugin_platform_interface 2.1.8 [meta]
- qr 3.0.2 [meta]
- shared_preferences 2.5.3 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows]
- shared_preferences_android 2.4.10 [flutter shared_preferences_platform_interface]
- shared_preferences_foundation 2.5.4 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.4.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.4.1 [flutter plugin_platform_interface]
- shared_preferences_web 2.4.3 [flutter flutter_web_plugins shared_preferences_platform_interface web]
- shared_preferences_windows 2.4.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface]
- sky_engine 0.0.0
- source_span 1.10.1 [collection path term_glyph]
- stack_trace 1.12.1 [path]
- stream_channel 2.1.4 [async]
- string_scanner 1.4.1 [source_span]
- term_glyph 1.2.2
- test_api 0.7.4 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- typed_data 1.4.0 [collection]
- url_launcher 6.3.2 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]
- url_launcher_android 6.3.16 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.3.3 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.2.1 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.2.2 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.3.2 [flutter plugin_platform_interface]
- url_launcher_web 2.4.1 [flutter flutter_web_plugins url_launcher_platform_interface web]
- url_launcher_windows 3.1.4 [flutter url_launcher_platform_interface]
- vector_math 2.1.4
- vm_service 14.3.1
- web 1.1.1
- win32 5.13.0 [ffi]
- xdg_directories 1.1.0 [meta path]

Additional context and comments

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions