Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure parsed body is an array when expecting Sequence #385

Merged
merged 6 commits into from
Apr 30, 2020

Conversation

joheredi
Copy link
Member

Issue:

When an operation spec defines that a response should be of type Sequence (array) but the service actually returns null/undefined instead of an empty list, we end up crashing with the following error as the empty response body gets deserialized as {}

TypeError: (_response.parsedBody || []).slice is not a function at flattenResponse (/mnt/c/Users/jepri/scratch/node_modules/@azure/ms-rest-js/dist/msRest.node.js:3518:62)
at /mnt/c/Users/jepri/scratch/node_modules/@azure/ms-rest-js/dist/msRest.node.js:3353:47
at at process._tickCallback (internal/process/next_tick.js:189:7)

See Azure/azure-sdk-for-js/issues/8445

Note: [...(_response.parsedBody || [])] gets compiled into (_response.parsedBody || []).slice().

Fix:
When we are expecting an array, make sure we have one before proceeding

lib/serviceClient.ts Outdated Show resolved Hide resolved
Copy link

@sasathy1 sasathy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. Thanks for this PR. Getting this PR checked in will definitely help us achieve better availability. We are seeing dips in our service availability due to this issue. It would be really great to see this checked in sooner.
Any idea on what is the estimated time to complete this PR? Also can we get a point of contact person to reach out to in case of future inquiries?

@ramya-rao-a
Copy link
Contributor

@sasathy1 Can you share which package are you using where you are seeing the issues that would be solved with this PR?

@joheredi
Copy link
Member Author

/azp run public.Azure.ms-rest-js - test dependent projects

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sasathy1
Copy link

@sasathy1 Can you share which package are you using where you are seeing the issues that would be solved with this PR?

We are using @azure/arm-eventhub and @azure/arm-servicebus(both are of version 3.2.0).

@joheredi
Copy link
Member Author

/azp run public.Azure.ms-rest-js - test dependent projects

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ramya-rao-a
Copy link
Contributor

Looks like we have a new error?

Screen Shot 2020-04-27 at 5 17 27 PM

@joheredi
Copy link
Member Author

/azp run public.Azure.ms-rest-js - test dependent projects

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@joheredi joheredi merged commit 118158b into Azure:master Apr 30, 2020
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