Skip to content

CUST-5800: Fall back to body request_id on API errors - #787

Merged
radenkovic merged 2 commits into
mainfrom
fix/CUST-5800-request-id-on-errors
Nov 24, 2026
Merged

radenkovic merged 2 commits into
mainfrom
fix/CUST-5800-request-id-on-errors

Conversation

@radenkovic

@radenkovic radenkovic commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes CUST-5800: error.requestId was undefined on some api.provider_error responses (seen as a 404 from POST /v3/grants/{id}/messages/send).

Cause: APIClient read requestId only from the x-request-id response header. It parsed the top-level request_id in the error body but never used it, so the ID was lost whenever the header was missing.

Change:

  • src/apiClient.ts: use the header when present, otherwise the body request_id, for both NylasApiError and NylasOAuthError.
  • src/models/error.ts: NylasApiError falls back to apiError.requestId when constructed directly.
  • CHANGELOG.md: entry under Unreleased → Fixed.

Errors from responses whose body isn't JSON still use the header only, since there is no body ID to read.

Tests

  • New: a 404 api.provider_error with a body request_id and no header sets requestId (fails without the fix).
  • New: the header takes precedence over the body value.
  • Full suite: 567 passed. tsc --noEmit and eslint are clean.

🤖 Generated with Claude Code

The SDK read requestId only from the x-request-id response header and
ignored the top-level request_id in the error body. When the header was
absent (as seen on api.provider_error 404s from /messages/send),
error.requestId was undefined.

Prefer the header, otherwise use the body request_id, for both
NylasApiError and NylasOAuthError. NylasApiError also falls back to the
body value when constructed directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.69%. Comparing base (ac35761) to head (884704d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #787   +/-   ##
=======================================
  Coverage   98.69%   98.69%           
=======================================
  Files          43       43           
  Lines        1075     1076    +1     
  Branches      101      103    +2     
=======================================
+ Hits         1061     1062    +1     
  Misses         12       12           
  Partials        2        2           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@radenkovic
radenkovic merged commit 02d0fc3 into main Nov 24, 2026
10 checks passed

This branch was successfully deployed

1 active deployment
sdk-reference — 884704d4 Deployed Nov 24, 2026 by radenkovic via docs #827
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