failure message is not properly escaped
ggrossetie opened this issue · 3 comments
ggrossetie commented
This is a junit.xml file produced when running Cypress:
<?xml version="1.0"?>
<testsuites failures="17" errors="0" tests="17" skipped="0">
<testsuite name="Root Suite" timestamp="2023-01-04T11:53:31" tests="0" file="src/e2e/my.spec.js" time="0.000" failures="0"/>
<testsuite name="Import" timestamp="2023-01-04T11:53:31" tests="1" time="7.026" failures="1">
<testcase name="Something "before each" hook for "TP-123 - successfully import something"" time="0.000" classname=""before each" hook for "TP-123 - successfully import something"">
<failure message="`cy.request()` failed on:
https://domain.com/api?clientId=123&spaceId=e00c157f-693c-4a57-9cf4-64be11755830%3Ae00c157f-693c-4a57-9cf4-64be11755830
The response we received from your web server was:
> 500: Internal Server Error
This was considered a failure because the status code was not `2xx` or `3xx`.
If you do not want status codes to cause failures pass the option: `failOnStatusCode: false`
-----------------------------------------------------------
The request we sent was:
Method: POST
URL: https://domain.com/api?clientId=123&spaceId=456
Headers: {
"Connection": "keep-alive",
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/108.0.5359.98 Safari/537.36",
"accept": "*/*",
"cookie": "DG_COOKIE={\"loginData\":{\"useAutoLogin\":true,\"loginToken\":\"111.222.333\",\"userLanguageCode\":\"fr\"}}",
"accept-encoding": "gzip, deflate",
"content-type": "application/json",
"content-length": 83
}
Body: {"UserSessionId":"123_master@domain.com"}
-----------------------------------------------------------
The response we got was:
Status: 500 - Internal Server Error
Headers: {
"date": "Wed, 04 Jan 2023 11:53:37 GMT",
"content-type": "application/json",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"cache-control": "no-cache, no-store, must-revalidate",
"expires": "-1",
"pragma": "no-cache",
"strict-transport-security": "max-age=31536000; includeSubDomains; preload",
"x-frame-options": "sameorigin",
"x-xss-protection": "1;mode=block",
"x-content-type-options": "nosniff"
}
Body: {
"StatusCode": 500,
"ErrorCode": 0,
"ErrorCodeString": "UnknownErrorCode",
"Message": "Response status code does not indicate success: 500 (Internal Server Error).",
"RequestNumber": 108,
"RequestXid": null,
"ServerXid": "888"
}
https://on.cypress.io/request
Because this error occurred during a `before each` hook we are skipping the remaining tests in the current suite: `Something`" type="CypressError"><![CDATA[CypressError: `cy.request()` failed on:
https://domain.com/api?clientId=123&spaceId=456
The response we received from your web server was:
> 500: Internal Server Error
This was considered a failure because the status code was not `2xx` or `3xx`.
If you do not want status codes to cause failures pass the option: `failOnStatusCode: false`
-----------------------------------------------------------
The request we sent was:
Method: POST
URL: https://domain.com/api?clientId=123&spaceId=e00c157f-693c-4a57-9cf4-64be11755830%3Ae00c157f-693c-4a57-9cf4-64be11755830
Headers: {
"Connection": "keep-alive",
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/108.0.5359.98 Safari/537.36",
"accept": "*/*",
"cookie": "DG_COOKIE={\"loginData\":{\"useAutoLogin\":true,\"loginToken\":\"111.222.333\",\"userLanguageCode\":\"fr\"}}",
"accept-encoding": "gzip, deflate",
"content-type": "application/json",
"content-length": 83
}
Body: {"UserSessionId":"123_master@domain.com"}
-----------------------------------------------------------
The response we got was:
Status: 500 - Internal Server Error
Headers: {
"date": "Wed, 04 Jan 2023 11:53:37 GMT",
"content-type": "application/json",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"cache-control": "no-cache, no-store, must-revalidate",
"expires": "-1",
"pragma": "no-cache",
"strict-transport-security": "max-age=31536000; includeSubDomains; preload",
"x-frame-options": "sameorigin",
"x-xss-protection": "1;mode=block",
"x-content-type-options": "nosniff"
}
Body: {
"StatusCode": 500,
"ErrorCode": 0,
"ErrorCodeString": "UnknownErrorCode",
"Message": "Response status code does not indicate success: 500 (Internal Server Error).",
"RequestNumber": 108,
"RequestXid": null,
"ServerXid": "888"
}
https://on.cypress.io/request
Because this error occurred during a `before each` hook we are skipping the remaining tests in the current suite: `Looker`
at <unknown> (https://domain.com/__cypress/runner/cypress_runner.js:144155:80)
at tryCatcher (https://domain.com/__cypress/runner/cypress_runner.js:11318:23)
at Promise._settlePromiseFromHandler (https://domain.com/__cypress/runner/cypress_runner.js:9253:31)
at Promise._settlePromise (https://domain.com/__cypress/runner/cypress_runner.js:9310:18)
at Promise._settlePromise0 (https://domain.com/__cypress/runner/cypress_runner.js:9355:10)
at Promise._settlePromises (https://domain.com/__cypress/runner/cypress_runner.js:9435:18)
at _drainQueueStep (https://domain.com/__cypress/runner/cypress_runner.js:6025:12)
at _drainQueue (https://domain.com/__cypress/runner/cypress_runner.js:6018:9)
at ../../node_modules/bluebird/js/release/async.js.Async._drainQueues (https://domain.com/__cypress/runner/cypress_runner.js:6034:5)
at Async.drainQueues (https://domain.com/__cypress/runner/cypress_runner.js:5904:14)
From Your Spec Code:
at Context.eval (webpack:///./src/support/commands.ts:215:11)]]></failure>
</testcase>
</testsuite>
</testsuites>
As you can see &
is not escaped:
23: 124 The reference to entity "spaceId" must end with the ';' delimiter.
Line 23, col 49 EntityRef: expecting ';'
bitcoder commented
Can you share an example of dummy cypress code forcing generation of such invalid message?
ggrossetie commented
I wasn't able to reproduce it using a dummy/simplified Cypress code 🤔
I will try to find out what's the root cause.
ggrossetie commented
I found the culprit! junit-report-merger
transform &
back to &
😬