Skip to content

healthCheck throws error #799

Closed
Closed
@catalunha

Description

@catalunha

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bounty:$20Bounty applies for fixing this issue (Parse Bounty Program)type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions