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

healthCheck throws error #799

Closed
catalunha opened this issue Nov 21, 2022 · 3 comments · Fixed by #802
Closed

healthCheck throws error #799

catalunha opened this issue Nov 21, 2022 · 3 comments · Fixed by #802
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@catalunha
Copy link

catalunha commented Nov 21, 2022

I'm building a tutorial for Parse Serve (using Back4app) and ran into this issue on SKD for Flutter.

New Issue Checklist

Issue Description

I tested the following code:

void main(List<String> arguments) async {
  // String appId = 'appIdCorrect';
  // String clientKey = 'clientKeyCorrect';
  String appId = 'appIdWrong';
  String clientKey = 'clientKeyWrong';
  String keyParseServerUrl = 'https://parseapi.back4app.com/';
  var parse = await Parse().initialize(
    appId,
    keyParseServerUrl,
    clientKey: clientKey,
    autoSendSessionId: true,
    debug: true,
  );
  print(
      'Parse().hasParseBeenInitialized(): ${parse.hasParseBeenInitialized()}');
  if (parse.hasParseBeenInitialized()) {
    var response = await parse.healthCheck();
    print('response.success: ${response.success}');
    print('Bach4App: Ok');
  } else {
    print('Bach4App: Not Ok');
  }
}

Steps to reproduce

Create a pure standard Dart project with VSCode
Create a basic project in back4app and write down the appId and clientKey.
Copy the code above to your Dart project and enter the correct appId and clientKey and then a wrong value.
Run the Dart project with:
$ dart bin/learning_about_b4a_dart.dart

Actual Outcome

If I put the correct appId and clientKey values I get:
Parse().hasParseBeenInitialized(): true
response.success: true
Bach4App: Ok

But if I put the wrong appId and clientKey values I get:
Parse().hasParseBeenInitialized(): true
Unhandled exception:
type 'Null' is not a subtype of type 'int'
#0 buildErrorResponse (package:parse_server_sdk/src/objects/response/parse_error_response.dart:8:25)
#1 _ParseResponseBuilder.handleResponse (package:parse_server_sdk/src/objects/response/parse_response_builder.dart:18:14)
#2 handleResponse (package:parse_server_sdk/src/objects/response/parse_response_utils.dart:8:31)
#3 Parse.healthCheck (package:parse_server_sdk/parse_server_sdk.dart:158:14)

#4 main (file:///home/catalunha/myapp/learning_about_b4a_dart/bin/learning_about_b4a_dart.dart:20:20)

There was an error when calling: await parse.healthCheck();

Expected Outcome

The return from await parse.healthCheck() is a Future so I would expect a parseResponse.success = false as I entered incorrect appId and clientKey values. But actually I get an error in the SDK.
🇧🇷
Because in my tutorial the user can change the appId and clientKey to test my tutorial.
So if it reports a wrong appId and clientKey I have an SDK error and not a parseResponse.success=false return.

Environment

Parse Flutter SDK

  • SDK version: parse_server_sdk_flutter: ^3.1.3
  • Operating system version: Description: Pop!_OS 22.04 LTS

Server

  • Parse Server version: 4.5.0

Logs

@parse-github-assistant
Copy link

parse-github-assistant bot commented Nov 21, 2022

Thanks for opening this issue!

  • ❌ Please edit your post and use the provided template when creating a new issue. This helps everyone to understand your post better and asks for essential information to quicker review the issue.

@mtrezza mtrezza added type:bug Impaired feature or lacking behavior that is likely assumed bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) labels Nov 21, 2022
@catalunha
Copy link
Author

Congratulations and thanks @mtrezza ,
I wish I had more knowledge to solve issues and not just create them.
I'm struggling here.

@mbfakourii
Copy link
Member

I'm not sure about the clientKey, but there is no validation on the parse server side for the clientKey being wrong, and no message is returned in this case! @mtrezza

and about wrong appId and error sent, I checked and found the problem and I'm trying to solve the problem in a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants