{"record":{"id":"f29538cf272c842c","repo":"juspay/hyperswitch","slug":"invalid-authentication-type-response-body-authe","errorCode":null,"errorMessage":"Invalid authentication type: ${response.body.authentication_type}","messagePattern":"Invalid authentication type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cypress-tests/cypress/support/commands.js","lineNumber":4087,"sourceCode":"                  globalState.set(\n                    \"nextActionUrl\",\n                    response.body.next_action.redirect_to_url\n                  );\n                }\n              }\n              for (const key in resData.body) {\n                expect(resData.body[key], [key]).to.deep.equal(\n                  response.body[key]\n                );\n              }\n            } else if (response.body.authentication_type === \"no_three_ds\") {\n              for (const key in resData.body) {\n                expect(resData.body[key], [key]).to.deep.equal(\n                  response.body[key]\n                );\n              }\n            } else {\n              throw new Error(\n                `Invalid authentication type: ${response.body.authentication_type}`\n              );\n            }\n          } else if (\n            response.body.capture_method === \"manual\" ||\n            response.body.capture_method === \"manual_multiple\"\n          ) {\n            if (response.body.authentication_type === \"three_ds\") {\n              if (response.body.next_action) {\n                if (response.body.next_action.type === \"invoke_ddc\") {\n                  expect(response.body.next_action)\n                    .to.have.property(\"type\")\n                    .to.equal(\"invoke_ddc\");\n                  globalState.set(\n                    \"nextActionUrl\",\n                    response.body.next_action.ddc_data.iframe_url\n                  );\n                } else if (response.body.next_action.three_ds_data) {","sourceCodeStart":4069,"sourceCodeEnd":4105,"githubUrl":"https://github.com/juspay/hyperswitch/blob/9b8b89dc378b62c9a6feda647bad4719d2de7699/cypress-tests/cypress/support/commands.js#L4069-L4105","documentation":"Guard-clause throw in the Cypress command createConfirmPaymentTest (cypress-tests/cypress/support/commands.js:4087), inside the branch for capture_method === 'automatic'. After a 200 create-and-confirm, the command only knows how to diff the response against resData when response.body.authentication_type is 'three_ds' or 'no_three_ds'; anything else throws. It indicates the created payment's authentication_type does not match the two combinations this fast-path validator implements.","triggerScenarios":"POST /payments (create + confirm) returns 200 with capture_method 'automatic' and authentication_type not in {three_ds, no_three_ds}: e.g. the fixture's authentication_type is misspelled, the field is null in the response, or a new enum value was introduced by the router.","commonSituations":"Typo in a fixture (e.g. 'no3ds', 'no_three_ds ' with whitespace); running against a router build where authentication_type is absent for some connectors; adding a new auth flow without extending createConfirmPaymentTest.","solutions":["Log response.body.authentication_type and the x-request-id header and diff it against the fixture's requested authentication_type.","Fix the fixture to request 'three_ds' or 'no_three_ds' explicitly.","If the router now emits a third legitimate authentication_type, add an else-if branch with the expected response diff for it."],"exampleFix":"// before\n} else if (response.body.authentication_type === \"no_three_ds\") {\n  for (const key in resData.body) { /* diff */ }\n} else {\n  throw new Error(`Invalid authentication type: ${response.body.authentication_type}`);\n}\n\n// after\n} else if (response.body.authentication_type === \"no_three_ds\") {\n  for (const key in resData.body) { /* diff */ }\n} else {\n  throw new Error(`Invalid authentication type: ${response.body.authentication_type} (request_id=${response.headers[\"x-request-id\"]}, fixture_expected=${authentication_type})`);\n}","handlingStrategy":"validation","validationCode":"const supportedAuth = [\"three_ds\", \"no_three_ds\"];\nif (!supportedAuth.includes(authentication_type)) {\n  throw new Error(`createConfirmPaymentTest automatic branch supports only three_ds|no_three_ds, got '${authentication_type}'`);\n}","typeGuard":"function isValidAuthenticationType(v) {\n  return v === \"three_ds\" || v === \"no_three_ds\";\n}","tryCatchPattern":"if (!isValidAuthenticationType(response.body.authentication_type)) {\n  throw new Error(`Invalid authentication type: ${response.body.authentication_type} (request_id=${response.headers[\"x-request-id\"]}, requested=${authentication_type})`);\n}","preventionTips":["Validate the spec's authentication_type argument before invoking createConfirmPaymentTest.","Add schema assertions for enum fields early in the command so failures point at the field, not a fall-through throw.","Regenerate fixtures from a validated template instead of hand-editing enum strings."],"tags":["cypress","hyperswitch","payments","test-assertion","authentication-type","enum-mismatch"],"backgroundTag":null,"analyzedSha":"9b8b89dc378b62c9a6feda647bad4719d2de7699","analyzedAt":"2026-08-16T09:01:53.433Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}