Parse-SDK-Flutter icon indicating copy to clipboard operation
Parse-SDK-Flutter copied to clipboard

fix: Http client exception not handled properly resulting in incorrectly formatted error

Open 2shrestha22 opened this issue 1 year ago โ€ข 8 comments

Pull Request

Issue

Closes: #1022

Approach

Tasks

  • [x] Add tests
  • [x] Add changes to documentation (guides, repository pages, code comments)

2shrestha22 avatar Nov 27 '24 17:11 2shrestha22

๐Ÿš€ Thanks for opening this pull request!

@mtrezza

Can you please run CI?

mbfakourii avatar Nov 28 '24 14:11 mbfakourii

@mbfakourii done

mtrezza avatar Nov 30 '24 17:11 mtrezza

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.

codecov[bot] avatar Nov 30 '24 17:11 codecov[bot]

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?

mtrezza avatar Dec 04 '24 01:12 mtrezza

I think it's better.

2shrestha22 avatar Dec 04 '24 01:12 2shrestha22

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.

mtrezza avatar Dec 08 '24 12:12 mtrezza

๐Ÿ“ 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.dart to ensure removed part directives didn't drop exported symbols or change public API composition.
  • Review buildParseResponseWithException changes for correct preservation of the original exception, numeric code parsing, and consistent ParseError shaping.
  • Run and review the added tests in parse_exception_response_test.dart to 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.

โค๏ธ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 15 '25 03:11 coderabbitai[bot]

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 avatar Nov 15 '25 03:11 2shrestha22

@2shrestha22 each PR merge triggers a release.

mtrezza avatar Nov 20 '25 11:11 mtrezza

@2shrestha22 each PR merge triggers a release.

updated

2shrestha22 avatar Nov 22 '25 01:11 2shrestha22

Fixed the CI issues in https://github.com/parse-community/Parse-SDK-Flutter/pull/1046, should all pass now

mtrezza avatar Nov 23 '25 15:11 mtrezza

Interesting, were there still some failing tests?

mtrezza avatar Nov 23 '25 16:11 mtrezza

Interesting, were there still some failing tests? There was not any test written initially that's why code coverage was failing.

2shrestha22 avatar Nov 23 '25 16:11 2shrestha22

Got it, is this ready for merge now?

mtrezza avatar Nov 23 '25 16:11 mtrezza

Yes ready to merge

2shrestha22 avatar Nov 23 '25 16:11 2shrestha22