fix: Http client exception not handled properly resulting in incorrectly formatted error
Pull Request
- Report security issues confidentially.
- Any contribution is under this license.
- Link this pull request to an issue.
Issue
Closes: #1022
Approach
Tasks
- [x] Add tests
- [x] Add changes to documentation (guides, repository pages, code comments)
๐ Thanks for opening this pull request!
@mtrezza
Can you please run CI?
@mbfakourii done
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 43.98%. Comparing base (20efcdf) to head (3d06272).
:warning: Report is 1 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #1021 +/- ##
==========================================
+ Coverage 43.72% 43.98% +0.26%
==========================================
Files 61 61
Lines 3465 3469 +4
==========================================
+ Hits 1515 1526 +11
+ Misses 1950 1943 -7
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
I will reformat the title to use the proper commit message syntax.
I rephrased the PR title; not sure whether it accurately describes the issue, could you please review?
I think it's better.
There is still an open review discussion and the changelog entry + version bump is missing in the PR. See other PRs on how they are done. Then we can go ahead and merge.
๐ Walkthrough
Walkthrough
Added an http import and removed many part directives from the main Dart library file; added explicit handling for http.ClientException and refined DioException parsing in the parse-exception response builder; bumped package version and added unit tests for exception handling.
Changes
| Cohort / File(s) | Summary |
|---|---|
Library entry changes packages/dart/lib/parse_server_sdk.dart |
Added import 'package:http/http.dart'; and removed numerous part directives that previously split the library into multiple parts. |
Exception handling packages/dart/lib/src/objects/response/parse_exception_response.dart |
Added handling for http.ClientException in buildParseResponseWithException; refined DioException handling to attempt parsing an integer code from the response before falling back to statusCode; returns ParseResponse with ParseError including the original exception. |
Tests packages/dart/test/src/objects/response/parse_exception_response_test.dart |
Added unit tests covering DioException (JSON and non-JSON bodies), http.ClientException, and generic Exception paths for buildParseResponseWithException. |
Metadata / docs packages/dart/CHANGELOG.md, packages/dart/pubspec.yaml |
Bumped package version to 8.0.1 and added changelog entry documenting the ClientException fix. |
Sequence Diagram(s)
sequenceDiagram
participant Client
participant SDK as Parse SDK
participant HTTP as http.Client
participant Builder as buildParseResponseWithException
Client->>SDK: perform request
SDK->>HTTP: send request
alt http.ClientException thrown
HTTP-->>SDK: throws ClientException
SDK->>Builder: buildParseResponseWithException(ClientException)
Builder-->>SDK: ParseResponse{ error: ParseError(message, exception) }
else DioException thrown
HTTP-->>SDK: throws DioException
SDK->>Builder: buildParseResponseWithException(DioException)
Builder-->>SDK: ParseResponse{ error: ParseError(parsedMessage, parsedCode, exception) }
else other Exception
HTTP-->>SDK: throws Exception
SDK->>Builder: buildParseResponseWithException(Exception)
Builder-->>SDK: ParseResponse{ error: ParseError(message, exception) }
end
SDK-->>Client: return ParseResponse (error)
Estimated code review effort
๐ฏ 3 (Moderate) | โฑ๏ธ ~25 minutes
- Inspect
parse_server_sdk.dartto ensure removedpartdirectives didn't drop exported symbols or change public API composition. - Review
buildParseResponseWithExceptionchanges for correct preservation of the original exception, numeric code parsing, and consistentParseErrorshaping. - Run and review the added tests in
parse_exception_response_test.dartto confirm coverage and expected behavior.
Pre-merge checks and finishing touches
โ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | โ Passed | The title accurately and clearly describes the main fix being implemented - handling HTTP client exceptions to produce properly formatted errors. |
| Description check | โ Passed | The PR description includes the required template structure with the linked issue (#1022), marks tasks as completed, but lacks a detailed Approach section explaining the implementation. |
| Linked Issues check | โ Passed | The PR successfully addresses issue #1022 by adding ClientException handling in buildParseResponseWithException with comprehensive tests and changelog entry. |
| Out of Scope Changes check | โ Passed | All changes are directly related to fixing HTTP client exception handling. The import addition and part directive removal in parse_server_sdk.dart appear to be refactoring, which is minimal and necessary. |
| Docstring Coverage | โ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
โจ Finishing touches
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
There is still an open review discussion and the changelog entry + version bump is missing in the PR. See other PRs on how they are done. Then we can go ahead and merge.
I thought changelog and version bump should be maintained on release instead of PR merge.
@2shrestha22 each PR merge triggers a release.
@2shrestha22 each PR merge triggers a release.
updated
Fixed the CI issues in https://github.com/parse-community/Parse-SDK-Flutter/pull/1046, should all pass now
Interesting, were there still some failing tests?
Interesting, were there still some failing tests? There was not any test written initially that's why code coverage was failing.
Got it, is this ready for merge now?
Yes ready to merge