TW-5059: fix WrapError request ID false-match and classification gaps#85
Merged
qasim-nylas merged 1 commit intoMay 15, 2026
Merged
Conversation
APIError instances with status codes not handled by the structured switch (401, 403, 404) fell through to string-matching on err.Error(), which now includes [request_id: ...] from PR #80. A request ID containing "502" or "429" as a substring could misclassify the error, and all string-match paths silently dropped the request ID. Extend the switch to cover 401, 403, 404, and a default catch-all so every APIError is classified by status code with its RequestID preserved. Remove redundant User-Agent set in doJSONRequestInternal.
AaronDDM
approved these changes
May 15, 2026
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
WrapErrorwhereAPIErrorinstances with status 401/403/404 fell through to string-matching onerr.Error(), which since PR TW-4937: surface API request ID in CLI error output #80 includes[request_id: ...]— a request ID containing "502" or "429" as a substring could misclassify the error, and all string-match paths silently dropped the request IDAPIErroris classified by status code withRequestIDpreserveddoJSONRequestInternalWithRetry(already set bydoRequest/doRequestNoRetry)Test plan
TestWrapError_RequestIDDoesNotFalseMatchStatusCode— regression test proving request IDs containing "502", "429", "500" don't cause misclassificationTestWrapError_APIErrorStatusClassification— expanded with 401, 403, 404 casesTestWrapError_PropagatesRequestID— all status code paths carry request IDTestWrapError_GenericForbiddenFallsThrough— generic 403 gets permission denied, not scope-specific suggestionsTestHTTPClient_UserAgent— User-Agent still sent on all requests after removing redundant setmake ci-fullpasses (4 pre-existing scheduler 404 failures unrelated to this change)Related docs