Repository navigation
CUST-5800: Fall back to body request_id on API errors - #787
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
AaronDDM
approved these changes
Nov 23, 2026
This branch was successfully deployed
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
Fixes CUST-5800:
error.requestIdwasundefinedon someapi.provider_errorresponses (seen as a 404 fromPOST /v3/grants/{id}/messages/send).Cause:
APIClientreadrequestIdonly from thex-request-idresponse header. It parsed the top-levelrequest_idin 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 bodyrequest_id, for bothNylasApiErrorandNylasOAuthError.src/models/error.ts:NylasApiErrorfalls back toapiError.requestIdwhen 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
api.provider_errorwith a bodyrequest_idand no header setsrequestId(fails without the fix).tsc --noEmitand eslint are clean.🤖 Generated with Claude Code