fix: check data is present before reading errors#309
Merged
Conversation
Signed-off-by: Rich Ellis <ricellis@users.noreply.github.com>
pyrooka
approved these changes
Nov 11, 2025
Member
pyrooka
left a comment
There was a problem hiding this comment.
Thanks a lot for adding the extra check to handle such cases! The new unit test case is also appreciated. Changes are looking good.
ibm-devx-sdk
pushed a commit
that referenced
this pull request
Nov 11, 2025
## [5.4.4](v5.4.3...v5.4.4) (2025-11-11) ### Bug Fixes * check data is present before reading errors ([#309](#309)) ([3001a0f](3001a0f))
|
🎉 This PR is included in version 5.4.4 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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.
Checklist
npm testpasses (tip:npm run lint-fixcan correct most style issues)Received a user report where a client-side disconnection results in:
I haven't been able to reproduce a client-side disconnection that results in an axios error that includes a
responseatnode-sdk-core/lib/request-wrapper.ts
Line 378 in 6a13d1d
but doesn't have
dataatnode-sdk-core/lib/request-wrapper.ts
Line 391 in 6a13d1d
Nonetheless
node-sdk-core/lib/request-wrapper.ts
Line 648 in 6a13d1d
(Note that
responsehere isresponse.datafrom theformatErrorfunction)since
parseServiceErrorMessagedeclaresresponse: any, but does not check forundefinedornull(which are permitted byany) before trying to access properties.This PR adds a guard clause to prevent accessing properties in the event the passed
response.data->responsewas not defined to avoid theTypeError.I added a test that fails before the change and passes after it validating that an error object without
response.datadoes not throw.Note: the build failures appear unrelated to this change, but rather an issue with a missing dependency.this worked on a re-run