Include errors[] detail when a 200 carries an error envelope (0.5.1)#7
Merged
Conversation
When a FedEx 200 response carries an errors[] envelope, pass the already-read body to HttpError.from(response, json) so the thrown error keeps the error messages and .json. Previously the body was consumed by response.json(), leaving a bare "200" error with no detail. Bumps @stores.com/http-error to ~1.2.0 and tightens the six 200-errors tests to assert the captured errors[] and message. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Coverage Report for CI Build 26486015917Coverage remained the same at 100.0%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When FedEx returns a 200 with an
errors[]envelope, the thrownHttpErrorwas bare ("200 ", no.json) — becauseawait response.json()had already consumed the body, so the follow-upHttpError.from(response)had nothing left to read.This passes the already-parsed body to the new two-argument form:
Now the error keeps the FedEx error messages (joined into
err.message) and the full body (err.json), while still carrying the response status andcause. The!response.okbranches are unchanged (the body is still fresh there).Applied to all six body-returning methods:
cancelShipment,createShipment,groundEndOfDayClose,rateAndTransitTimes,trackByTrackingNumber,validateAddress.Changes
@stores.com/http-errorto~1.2.0(the version that added the secondfrom(response, json)argument).err.json.errorsis captured anderr.messageis no longer the bare status.Testing
node --test --test-force-exit— the six envelope tests pass with the new assertions; mock-based suite green. (Live integration tests require FedEx credentials and run in CI.)🤖 Generated with Claude Code