Skip to content

Conversation

@ricellis
Copy link
Member

@ricellis ricellis commented Nov 6, 2025

Checklist
  • npm test passes (tip: npm run lint-fix can correct most style issues)
  • tests are included
  • documentation is changed or added

Received a user report where a client-side disconnection results in:

TypeError: Cannot read properties of undefined (reading 'errors')
at parseServiceErrorMessage (node_modules\ibm-cloud-sdk-core\lib\request-wrapper.js:630:32)
at RequestWrapper.formatError (node_modules\ibm-cloud-sdk-core\lib\request-wrapper.js:391:29)
at node_modules\ibm-cloud-sdk-core\lib\request-wrapper.js:364:45
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

I haven't been able to reproduce a client-side disconnection that results in an axios error that includes a response at

if (axiosError.response) {

but doesn't have data at
error.message = parseServiceErrorMessage(axiosError.data) || axiosError.statusText;

Nonetheless

function parseServiceErrorMessage(response: any): string | undefined {

(Note that response here is response.data from the formatError function)
since parseServiceErrorMessage declares response: any, but does not check for undefined or null (which are permitted by any) before trying to access properties.

This PR adds a guard clause to prevent accessing properties in the event the passed response.data -> response was not defined to avoid the TypeError.

I added a test that fails before the change and passes after it validating that an error object without response.data does 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

@CLAassistant
Copy link

CLAassistant commented Nov 6, 2025

CLA assistant check
All committers have signed the CLA.

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.

3 participants