Parse-SDK-Flutter
Parse-SDK-Flutter copied to clipboard
fix: the Response from DioError could return null from the data property but String is expected in ParseNetworkResponse
New Pull Request Checklist
- [x] I am not disclosing a vulnerability.
- [x] I am creating this PR in reference to an issue.
Issue Description
The response from dio
error object could have a null data
property
Related issue: https://github.com/parse-community/Parse-SDK-Flutter/issues/774
Approach
Add null aware operator ??
:
on dio.DioError catch (error) {
return ParseNetworkByteResponse(
data: error.response?.data ?? _fallbackErrorData,
statusCode: error.response!.statusCode!,
);
}
TODOs before merging
All set
- [ ] Add tests
- [ ] Add changes to documentation (guides, repository pages, in-code descriptions)
- [ ] A changelog entry
Thanks for opening this pull request!
- 🎉 We are excited about your hands-on contribution!
Could you please replace the PR title with fix: <summary of what the issue is>
; I assume the related issue is https://github.com/parse-community/Parse-SDK-Flutter/pull/775, I have added this to your PR description.
I will reformat the title to use the proper commit message syntax.
Sure, but I can not find a way to mock the _ParseDioClient
class to fake the DioError
.
I was thinking of adding a typedef like this:
typedef ParseDioClientForMockTest = _ParseDioClient;
so I can create a mock for it and inject it in the constructor of ParseDioClient
maybe like this:
ParseDioClient({
bool sendSessionId = false,
SecurityContext? securityContext,
_ParseDioClient? parseDioClientForMockTest,
}) {
_client = parseDioClientForMockTest ??
_ParseDioClient(
sendSessionId: sendSessionId,
securityContext: securityContext,
);
}
But this requires the 'nonfunction-type-aliases' language feature to be enabled, so we need to set the minimum SDK constraint to 2.16.0
or higher.
Do you have any suitable way to do this?
Codecov Report
Base: 10.26% // Head: 10.08% // Decreases project coverage by -0.18%
:warning:
Coverage data is based on head (
2b3b05d
) compared to base (14be107
). Patch coverage: 0.00% of modified lines in pull request are covered.
Additional details and impacted files
@@ Coverage Diff @@
## master #775 +/- ##
==========================================
- Coverage 10.26% 10.08% -0.19%
==========================================
Files 49 47 -2
Lines 2815 2817 +2
==========================================
- Hits 289 284 -5
- Misses 2526 2533 +7
Impacted Files | Coverage Δ | |
---|---|---|
...ackages/dart/lib/src/network/parse_dio_client.dart | 0.00% <0.00%> (ø) |
|
packages/dart/lib/src/network/options.dart | 0.00% <0.00%> (-50.00%) |
:arrow_down: |
...ackages/dart/lib/src/network/parse_live_query.dart | 0.00% <0.00%> (-0.92%) |
:arrow_down: |
packages/flutter/lib/parse_server_sdk.dart | 8.77% <0.00%> (ø) |
|
packages/dart/lib/src/objects/parse_file.dart | 0.00% <0.00%> (ø) |
|
packages/dart/lib/src/objects/parse_user.dart | 0.00% <0.00%> (ø) |
|
packages/dart/lib/src/objects/parse_file_web.dart | 0.00% <0.00%> (ø) |
|
packages/dart/lib/src/objects/parse_file_base.dart | 0.00% <0.00%> (ø) |
|
...ckages/dart/lib/src/network/parse_http_client.dart | 5.12% <0.00%> (ø) |
|
... and 6 more |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
@parse-community/flutter-sdk-review what do you think, is this ready for merge?
@Nidal-Bakir any particular reason for closing this?
@parse-community/flutter-sdk-review should this PR be merged?
@mtrezza I'm sorry, I did not mean to close the PR! I did not know that if I deleted the forked repository from my account all my PR would be closed.
I was testing some things in my forked repository so I got to a point where I just needed to start from the beginning. so found it easier to just delete the repository and start all over again.
I've reopened, thanks for clarifying
Reopening in a different PR because I lost all the progress and the reference of these changes. The new PR pull/825