Repository navigation
Conversation
canRaiseHTTPError assumed response.data.error.type always exists. When the API (or a proxy) answers with a body of another shape, such as a plain-text 400, it threw a TypeError that hid the real HTTP error. Now the Fintoc error is only raised when error.type is a string; otherwise the original error is re-thrown. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
mrKanoh
marked this pull request as ready for review
November 6, 2026 23:30
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.
Description
Fixes #19.
canRaiseHTTPErrorassumed that every HTTP error response carries a body shaped like{ error: { type, ... } }. When the response comes from somewhere else (for example a 400 from a proxy or load balancer with a non-JSON body such as400 Bad Request),response.data.errorisundefinedand the decorator threwTypeError: Cannot read properties of undefined (reading 'type'). That hid the real HTTP error from the caller.What changes: the Fintoc error class is only raised when
response.data.erroris an object whosetypeis a string. In any other case the original AxiosError is re-thrown unchanged, so its status and response are preserved.Tests: 8 new cases in
src/spec/utils/canRaiseHTTPError.spec.ts. Seven cover bodies without a usableerror.type(string, HTML,{},{ error: {} }, non-objecterror,undefined,null) and expect the original error to be re-thrown; one control checks that a well-formedinvalid_request_errorbody still raisesInvalidRequestError. The seven re-throw cases failed withTypeErrorbefore the change.yarn buildandyarn lintpass, and the suite is at 349 passing (341 before).Requirements
None.
Additional changes
None. The version is not bumped, as
AGENTS.mdasks.🤖 Generated with Claude Code