Skip to content

[cloud_functions] Throws CloudFunctionsException in right cases #2556

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

Closed
wants to merge 2 commits into from

Conversation

kikuchy
Copy link

@kikuchy kikuchy commented May 14, 2020

Description

cloud_functions throws PlatformException when the error caused by Http Callable functions.
In some cases, it should throw CloudFunctionsExceprion instead of PlatformException.

There is no async-await keyword in spite of using try-catch (it should use then(onError:) argument instead of try-catch if don't use async-await).

Related Issues

#2069

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • If the pull request affects only one plugin, the PR title starts with the name of the plugin in brackets (e.g. [cloud_firestore])
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing. <- There are some already failing tests on my local computer (Channel stable, v1.17.0, on Mac OS X 10.15.4 19E287, locale ja-JP) but on CI, it passed
Result of test on current master $ pub global run flutter_plugin_tools test --plugins cloud_functions RUNNING cloud_functions/cloud_functions tests... Running "flutter pub get" in cloud_functions... 1.2s 00:00 +0: loading /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions/test/cloud_functions_test.dart 00:01 +0: loading /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions/test/cloud_functions_test.dart 00:02 +0: loading /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions/test/cloud_functions_test.dart 00:02 +0: CloudFunctions call 00:02 +1: CloudFunctions call 00:02 +1: All tests passed! Invalidating asset graph due package config update! ERROR - 2020-05-14 22:28:41.343377 GET /packages/ui/assets/Roboto-Regular.ttf Error thrown by handler. Invalid argument (packageUri): No package named "ui": Instance of '_Uri' package:package_config/src/packages_impl.dart 49:7 PackagesBase.resolve package:flutter_tools/src/test/flutter_web_platform.dart 224:36 FlutterWebPlatform._packageFilesHandler ===== asynchronous gap =========================== package:shelf/shelf_io.dart 63:34 serveRequests.. ===== asynchronous gap =========================== package:shelf/src/io_server.dart 53:5 IOServer.mount package:flutter_tools/src/test/flutter_web_platform.dart 79:13 new FlutterWebPlatform._ package:flutter_tools/src/test/flutter_web_platform.dart 95:31 FlutterWebPlatform.start dart:async _completeOnAsyncReturn package:http_multi_server/http_multi_server.dart HttpMultiServer._loopback ===== asynchronous gap =========================== dart:async _asyncThenWrapperHelper package:flutter_tools/src/test/runner.dart 132:37 _FlutterTestRunnerImpl.runTests. dart:async new Future.sync package:async/src/async_memoizer.dart 43:45 AsyncMemoizer.runOnce package:test_core/src/runner/loader.dart 230:28 Loader.loadFile. package:test_core/src/runner/load_suite.dart 98:31 new LoadSuite.. package:test_core/src/runner/load_suite.dart 108:8 new LoadSuite. package:test_api/src/backend/invoker.dart 400:30 Invoker._onRun.... ===== asynchronous gap =========================== dart:async new Future package:test_api/src/backend/invoker.dart 399:21 Invoker._onRun... dart:async runZoned package:test_api/src/backend/invoker.dart 387:9 Invoker._onRun.. dart:async runZoned package:test_api/src/backend/invoker.dart 148:7 Invoker.guard package:test_api/src/backend/invoker.dart 436:15 Invoker._guardIfGuarded package:test_api/src/backend/invoker.dart 386:7 Invoker._onRun. package:stack_trace Chain.capture package:test_api/src/backend/invoker.dart 385:11 Invoker._onRun package:test_api/src/backend/live_test_controller.dart 197:11 LiveTestController._run package:test_api/src/backend/live_test_controller.dart 50:37 _LiveTest.run

RUNNING cloud_functions/cloud_functions/example tests...
00:00 +0: loading /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions/example/test/cloud_functions_test.dart 00:01 +0: loading /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions/example/test/cloud_functions_test.dart 00:02 +0: loading /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions/example/test/cloud_functions_test.dart 00:02 +0: CloudFunctions example widget test 00:03 +0: CloudFunctions example widget test 00:03 +1: CloudFunctions example widget test 00:03 +1: All tests passed!
RUNNING cloud_functions/cloud_functions_platform_interface tests...
00:00 +0: loading /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions_platform_interface/test/cloud_functions_platform_interface_test.dart 00:01 +0: loading /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions_platform_interface/test/cloud_functions_platform_interface_test.dart 00:02 +0: loading /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions_platform_interface/test/cloud_functions_platform_interface_test.dart 00:02 +0: loading /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions_platform_interface/test/method_channel_cloud_functions_test.dart 00:02 +0: ... CloudFunctionsPlatform() MethodChannelCloudFunctions is the default instance 00:02 +1: loading /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions_platform_interface/test/method_channel_cloud_functions_test.dart 00:02 +1: /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions_platform_interface/test/cloud_functions_platform_interface_test.dart: ... Cannot be implemented with `i00:02 +2: loading /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions_platform_interface/test/method_channel_cloud_functions_test.dart 00:02 +2: /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions_platform_interface/test/cloud_functions_platform_interface_test.dart: CloudFunctionsPlatform() Can be e00:02 +3: /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions_platform_interface/test/method_channel_cloud_functions_test.dart: CloudFunctionsPlatform call 00:02 +4: /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions_platform_interface/test/method_channel_cloud_functions_test.dart: CloudFunctionsPlatform call 00:02 +4 -1: /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions_platform_interface/test/method_channel_cloud_functions_test.dart: CloudFunctionsPlatform call [E]
Expected: [
<has method name: 'CloudFunctions#call' with arguments: {
'app': '[DEFAULT]',
'region': null,
'origin': null,
'functionName': 'baz',
'timeoutMicroseconds': null,
'parameters': null
}>,
<has method name: 'CloudFunctions#call' with arguments: {
'app': '1337',
'region': 'space',
'origin': null,
'functionName': 'qux',
'timeoutMicroseconds': 25920000000000,
'parameters': {'quux': 'quuz'}
}>,
<has method name: 'CloudFunctions#call' with arguments: {
'app': '[DEFAULT]',
'region': null,
'origin': 'http://localhost:5001',
'functionName': 'bez',
'timeoutMicroseconds': null,
'parameters': null
}>
]
Actual: [
MethodCall:MethodCall(CloudFunctions#call, {app: __FIRAPP_DEFAULT, region: null, origin: null, timeoutMicroseconds: null, functionName: baz, parameters: null}),
MethodCall:MethodCall(CloudFunctions#call, {app: 1337, region: space, origin: null, timeoutMicroseconds: 25920000000000, functionName: qux, parameters: {quux: quuz}}),
MethodCall:MethodCall(CloudFunctions#call, {app: __FIRAPP_DEFAULT, region: null, origin: http://localhost:5001, timeoutMicroseconds: null, functionName: bez, parameters: null})
]
Which: does not match has method name: 'CloudFunctions#call' with arguments: {
'app': '[DEFAULT]',
'region': null,
'origin': null,
'functionName': 'baz',
'timeoutMicroseconds': null,
'parameters': null
} at location [0]

package:test_api expect
package:flutter_test/src/widget_tester.dart 348:3 expect
method_channel_cloud_functions_test.dart 52:7 main..

00:02 +4 -1: Some tests failed.
RUNNING cloud_functions/cloud_functions_web tests...
00:00 +0: loading /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions_web/test/cloud_functions_web_test.dart 00:01 +0: loading /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions_web/test/cloud_functions_web_test.dart 00:02 +0: loading /Users/kikuchy/tmp/flutterfire/packages/cloud_functions/cloud_functions_web/test/cloud_functions_web_test.dart 00:02 +0: CloudFunctionsWeb setUp wires up mock objects properly 00:02 +1: CloudFunctionsWeb setUp wires up mock objects properly 00:02 +1: CloudFunctionsWeb callCloudFunction calls down to Firebase API 00:02 +2: CloudFunctionsWeb callCloudFunction calls down to Firebase API 00:02 +2: All tests passed!
ERROR - 2020-05-14 22:29:08.240528
GET /packages/ui/assets/Roboto-Regular.ttf
Error thrown by handler.
Invalid argument (packageUri): No package named "ui": Instance of '_Uri'
package:package_config/src/packages_impl.dart 49:7 PackagesBase.resolve
package:flutter_tools/src/test/flutter_web_platform.dart 224:36 FlutterWebPlatform.packageFilesHandler
===== asynchronous gap ===========================
package:shelf/shelf_io.dart 63:34 serveRequests..
===== asynchronous gap ===========================
package:shelf/src/io_server.dart 53:5 IOServer.mount
package:flutter_tools/src/test/flutter_web_platform.dart 79:13 new FlutterWebPlatform.

package:flutter_tools/src/test/flutter_web_platform.dart 95:31 FlutterWebPlatform.start
dart:async _completeOnAsyncReturn
package:http_multi_server/http_multi_server.dart HttpMultiServer._loopback
===== asynchronous gap ===========================
dart:async _asyncThenWrapperHelper
package:flutter_tools/src/test/runner.dart 132:37 _FlutterTestRunnerImpl.runTests.
dart:async new Future.sync
package:async/src/async_memoizer.dart 43:45 AsyncMemoizer.runOnce
package:test_core/src/runner/loader.dart 230:28 Loader.loadFile.
package:test_core/src/runner/load_suite.dart 98:31 new LoadSuite..
package:test_core/src/runner/load_suite.dart 108:8 new LoadSuite.
package:test_api/src/backend/invoker.dart 400:30 Invoker._onRun....
===== asynchronous gap ===========================
dart:async new Future
package:test_api/src/backend/invoker.dart 399:21 Invoker._onRun...
dart:async runZoned
package:test_api/src/backend/invoker.dart 387:9 Invoker._onRun..
dart:async runZoned
package:test_api/src/backend/invoker.dart 148:7 Invoker.guard
package:test_api/src/backend/invoker.dart 436:15 Invoker._guardIfGuarded
package:test_api/src/backend/invoker.dart 386:7 Invoker._onRun.
package:stack_trace Chain.capture
package:test_api/src/backend/invoker.dart 385:11 Invoker._onRun
package:test_api/src/backend/live_test_controller.dart 197:11 LiveTestController._run
package:test_api/src/backend/live_test_controller.dart 50:37 _LiveTest.run

Tests for the following packages are failing (see above):

  • cloud_functions/cloud_functions_platform_interface
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@tzvc
Copy link

tzvc commented Jan 14, 2021

Any updates on this ?

@cubuspl42
Copy link
Contributor

AFAIK, it's fixed in upstream.

@Salakar
Copy link
Member

Salakar commented Apr 21, 2021

Thanks for this PR though I am closing as it has already been fixed upstream, sorry about that 🙈

@Salakar Salakar closed this Apr 21, 2021
@firebase firebase locked and limited conversation to collaborators May 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants