-
Notifications
You must be signed in to change notification settings - Fork 4.1k
fix(fdc): issue where if path was empty on web, the app crashed #17704
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
Conversation
packages/firebase_data_connect/firebase_data_connect/example/lib/main.dart
Outdated
Show resolved
Hide resolved
packages/firebase_data_connect/firebase_data_connect/example/lib/main.dart
Outdated
Show resolved
Hide resolved
@cynthiajoan , @yuchenshi @Lyokone Also, I see other potential bugs in the code that need your attention and this can be solved by using the pattern matching otherwise we can have all other bunch of potential runtime exception. instead of this:
In the handleError you have the same issue...you are assuming the keys in the json will be present
Maybe in the JsonGraphqlResponseError you can change the variables to be nullable or throw an explicit error, because the error can be either a null runtime exception or a type cast exception! Here is an example of how you can achieve the same without creating new methods and new class...so this will be more efficient because we do not need to instantiate a class to only pass data...Im not sure about the DataConnectRestContractException, but this in my opinion will help your team making sure the contract is respected with the backend and can be catch in your integration tests :-)
|
@wer-mathurin The |
@wer-mathurin we also do a check above that function to check whether the |
In this case my suggestion is even more appealing, because you can remove the if....less indentations equal a more readable code :-). And I think using pattern matching over imbricated if statements is a cleaner approach.
This is why I'm suggesting to add a DataConnectRestContractException...this will shield the Dart SDK from contract change from the DataConnect backend...if they decided to change the response format...the SDK will fail to read those "always sent" keys in the JSON. But you need to have an Integration test for that. |
@wer-mathurin Thanks for your suggestion. Though I will say, the |
I was thinking that the the code in the Dart SDK is maintained or contributed was done by people familiar with the Dart language :-) For the JSON validation and data extraction this is one of the use case documented by the Dart team : https://dart.dev/language/patterns#validating-incoming-json Cheers, |
@wer-mathurin Updated the PR. The new changes should be similar to what you suggested |
Fixes firebase/firebase-tools#9073