Skip to content

Commit 4e7c7bf

Browse files
committed
Updating logic for 422
1 parent 6780197 commit 4e7c7bf

File tree

1 file changed

+2
-7
lines changed
  • packages/server/lib/cloud

1 file changed

+2
-7
lines changed

packages/server/lib/cloud/api.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,20 @@ const rp = request.defaults((params: CypressRequestOptions, callback) => {
8888
if (params.encrypt === true || params.encrypt === 'always') {
8989
const { secretKey, jwe } = await enc.encryptRequest(params)
9090

91-
// TODO: double check the logic below here with @tgriesser
9291
params.transform = async function (body, response) {
9392
const { statusCode } = response
9493

9594
// response is valid and we are encrypting
9695
if (response.headers['x-cypress-encrypted'] || params.encrypt === 'always') {
9796
let decryptedBody
9897

99-
// TODO: if body is null/undefined throw a custom error
100-
10198
try {
10299
decryptedBody = await enc.decryptResponse(body, secretKey)
103100
} catch (e) {
104101
// we failed decrypting the response...
105102

106103
// if status code is >=500 or 404 just return body
107-
if (statusCode >= 500 || statusCode === 404 || statusCode === 422) {
104+
if (statusCode >= 500 || statusCode === 404) {
108105
return body
109106
}
110107

@@ -113,7 +110,6 @@ const rp = request.defaults((params: CypressRequestOptions, callback) => {
113110

114111
// If we've hit an encrypted payload error case, we need to re-constitute the error
115112
// as it would happen normally, with the body as an error property
116-
// TODO: need to look harder at this to better understand why its necessary
117113
if (response.statusCode > 400) {
118114
throw new RequestErrors.StatusCodeError(response.statusCode, decryptedBody, {}, decryptedBody)
119115
}
@@ -184,8 +180,8 @@ const retryWithBackoff = (fn) => {
184180
return attempt(retryIndex)
185181
})
186182
})
187-
// TODO: look at this too
188183
.catch(RequestErrors.TransformError, (err) => {
184+
// Unroll the error thrown from within the transform
189185
throw err.cause
190186
})
191187
}
@@ -258,7 +254,6 @@ module.exports = {
258254
}
259255
},
260256

261-
// TODO: i think we can remove this function
262257
resetPreflightResult () {
263258
recordRoutes = apiRoutes
264259
preflightResult = {

0 commit comments

Comments
 (0)