Skip to content

Include errors[] detail when a 200 carries an error envelope (0.5.1)#7

Merged
freshlogic merged 1 commit into
mainfrom
errors-envelope-detail
May 27, 2026
Merged

Include errors[] detail when a 200 carries an error envelope (0.5.1)#7
freshlogic merged 1 commit into
mainfrom
errors-envelope-detail

Conversation

@freshlogic

Copy link
Copy Markdown
Member

Summary

When FedEx returns a 200 with an errors[] envelope, the thrown HttpError was bare ("200 ", no .json) — because await response.json() had already consumed the body, so the follow-up HttpError.from(response) had nothing left to read.

This passes the already-parsed body to the new two-argument form:

const json = await response.json();
if (json.errors?.length) {
    throw await HttpError.from(response, json);   // was: from(response)
}

Now the error keeps the FedEx error messages (joined into err.message) and the full body (err.json), while still carrying the response status and cause. The !response.ok branches are unchanged (the body is still fresh there).

Applied to all six body-returning methods: cancelShipment, createShipment, groundEndOfDayClose, rateAndTransitTimes, trackByTrackingNumber, validateAddress.

Changes

  • Bump @stores.com/http-error to ~1.2.0 (the version that added the second from(response, json) argument).
  • Tighten the six "200 response with errors envelope" tests to assert err.json.errors is captured and err.message is 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

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>
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 26486015917

Coverage remained the same at 100.0%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 6 of 6 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 324
Covered Lines: 324
Line Coverage: 100.0%
Relevant Branches: 50
Covered Branches: 50
Branch Coverage: 100.0%
Branches in Coverage %: Yes
Coverage Strength: 16.95 hits per line

💛 - Coveralls

@freshlogic freshlogic merged commit e8e8444 into main May 27, 2026
2 checks passed
@freshlogic freshlogic deleted the errors-envelope-detail branch May 27, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants