Skip to content
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

[Discover] fix error construction and retrieving status #8807

Merged

Conversation

joshuali925
Copy link
Member

Description

This is a follow up fix for #8565, in case response.data.body is an Error object, passing it to Error constructor calls String(Error) which returns [object object]. Additionally, if error.message is a valid JSON, the route will get status code from JSON.parse(error.message).status, which is not always present.

The PR changes error construction to use response.data.body.message if available, and uses error.status if status is not available in parsed JSON.

Issues Resolved

Screenshot

Testing the changes

Changelog

  • skip

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link

codecov bot commented Nov 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.78%. Comparing base (78204a0) to head (ae58e67).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8807   +/-   ##
=======================================
  Coverage   60.78%   60.78%           
=======================================
  Files        3798     3798           
  Lines       90701    90701           
  Branches    14284    14284           
=======================================
  Hits        55135    55135           
  Misses      32067    32067           
  Partials     3499     3499           
Flag Coverage Δ
Linux_1 29.05% <ø> (ø)
Linux_2 56.39% <ø> (ø)
Linux_3 37.65% <ø> (-0.01%) ⬇️
Linux_4 29.82% <100.00%> (ø)
Windows_1 29.06% <ø> (ø)
Windows_2 56.34% <ø> (ø)
Windows_3 37.66% <ø> (ø)
Windows_4 29.82% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joshuali925 joshuali925 merged commit 016f090 into opensearch-project:main Nov 6, 2024
71 of 73 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Nov 6, 2024
Signed-off-by: Joshua Li <[email protected]>
(cherry picked from commit 016f090)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
joshuali925 pushed a commit that referenced this pull request Nov 7, 2024
(cherry picked from commit 016f090)

Signed-off-by: Joshua Li <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
all-star-contributor backport 2.x Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants