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

Exception in parseBody (parseWSManResponseBody.ts) #661

Closed
orinem opened this issue Aug 1, 2022 · 0 comments · Fixed by #734
Closed

Exception in parseBody (parseWSManResponseBody.ts) #661

orinem opened this issue Aug 1, 2022 · 0 comments · Fixed by #734
Labels
bug Something isn't working

Comments

@orinem
Copy link
Contributor

orinem commented Aug 1, 2022

Describe the bug 🪲

It's possible for AMT to return status code 400 with no body (Content-Length: 0). In this case, parseBody() attempts to access message.body.text and throws an exception.

To Reproduce 🪜

It may well occur randomly due to an underlying problem with splitting writes of a request using chunked encoding to CIRA channels. This pull request discusses one such case

Expected behavior

A suitable error should be returned, either '' or null. It could be as simple as:

  if (message.bodySize === 0) {
    return ''
  }

Alternatively, it shouldn't even be called if bodySize is zero.

AMT Device (please complete the following information): 🖥️

  • OS: Windows
  • AMT Version: 15.0.41
  • AMT Configuration Mode: CCM
  • Network Configuration: Dynamic IP

Service Deployment (please complete the following information): ⛈️

  • Deployment Type: Docker
  • Node Version: 16
  • Component & Version: mps latest

Additional context

Debug trace showing message object passed to parseBody():

2022-08-01T18:54:20.997Z silly: parseBody: {
        "protocolVersion": "HTTP/1.1",
        "statusCode": 400,
        "statusMessage": "Bad Request",
        "headersSize": 143,
        "bodySize": 0,
        "headers": [
                {
                        "name": "Date",
                        "value": "Mon, 1 Aug 2022 18:54:20 GMT"
                },
                {
                        "name": "Server",
                        "value": "Intel(R) Active Management Technology 15.0.41.2142"
                },
                {
                        "name": "Content-Length",
                        "value": "0"
                }
        ]
}
2022-08-01T18:54:20.997Z error: Exception during alarm occurrences request : TypeError: Cannot read properties of undefined (reading 'text')
2022-08-01T18:54:20.998Z info: TypeError: Cannot read properties of undefined (reading 'text')
    at parseBody (/mps-microservice/dist/utils/parseWSManResponseBody.js:13:25)
orinem added a commit to orinem/mps that referenced this issue Nov 20, 2022
orinem added a commit to orinem/mps that referenced this issue Nov 20, 2022
orinem added a commit to orinem/mps that referenced this issue Nov 20, 2022
orinem added a commit to orinem/mps that referenced this issue Nov 20, 2022
@matt-primrose matt-primrose linked a pull request Nov 21, 2022 that will close this issue
2 tasks
@matt-primrose matt-primrose added this to the November Release milestone Nov 21, 2022
rsdmike added a commit that referenced this issue Nov 22, 2022
Co-authored-by: Mike <michael.johanson@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants