{"record":{"id":"de851ca980ef3094","repo":"juspay/hyperswitch","slug":"invalid-capture-method-response-body-capture-met","errorCode":null,"errorMessage":"Invalid capture method ${response.body.capture_method}","messagePattern":"Invalid capture method (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cypress-tests/cypress/support/commands.js","lineNumber":3426,"sourceCode":"                );\n                if (\n                  response.body.setup_future_usage === \"off_session\" &&\n                  response.body.status === \"succeeded\" &&\n                  globalState.get(\"connectorId\") !== \"tsys_transit\"\n                ) {\n                  expect(\n                    response.body.connector_mandate_id,\n                    \"connector_mandate_id\"\n                  ).to.not.be.null;\n                }\n              }\n            } else {\n              throw new Error(\n                `Invalid authentication type ${response.body.authentication_type}`\n              );\n            }\n          } else {\n            throw new Error(\n              `Invalid capture method ${response.body.capture_method}`\n            );\n          }\n        } else {\n          defaultErrorHandler(response, resData);\n        }\n      });\n    });\n  }\n);\n\nCypress.Commands.add(\n  \"confirmCallAutoRetryTest\",\n  (confirmBody, data, confirm, globalState) => {\n    const { Request: reqData = {}, Response: resData = {} } = data || {};\n\n    const apiKey = globalState.get(\"publishableKey\");\n    const baseUrl = globalState.get(\"baseUrl\");","sourceCodeStart":3408,"sourceCodeEnd":3444,"githubUrl":"https://github.com/juspay/hyperswitch/blob/9b8b89dc378b62c9a6feda647bad4719d2de7699/cypress-tests/cypress/support/commands.js#L3408-L3444","documentation":"Thrown by the confirmCallTest command (cypress-tests/cypress/support/commands.js:3426) when a successful (200) confirm response carries a capture_method outside the modeled set {automatic, manual, manual_multiple}. The command dispatches its assertion tree on capture_method; an unrecognized value (new enum, undefined) falls straight into this throw.","triggerScenarios":"The API returns a capture_method the command predates (e.g. a scheduled or new auto-variant enum); the field is undefined because the response shape changed; the fixture requested an exotic capture method the confirm tree never modeled.","commonSituations":"Backend upgrades adding capture_method values without updating the Cypress command; response-schema drift; copy-pasted fixtures carrying unsupported capture methods.","solutions":["Log response.body.capture_method to see the exact unrecognized value","Align the request fixture's capture_method with automatic/manual/manual_multiple","If the new enum is legitimate, extend the command's allow-list/branches","Verify the create-intent step actually accepted your capture_method rather than defaulting it"],"exampleFix":"// before — chained literals, throws on any new enum\n} else if (\n  response.body.capture_method === 'manual' ||\n  response.body.capture_method === 'manual_multiple'\n) { /* ... */ } else {\n  throw new Error(`Invalid capture method ${response.body.capture_method}`);\n}\n// after — single source of truth with a self-describing failure\nconst CAPTURE_METHODS = ['automatic', 'manual', 'manual_multiple'];\nif (CAPTURE_METHODS.includes(response.body.capture_method)) { /* ... */ } else {\n  throw new Error(`Invalid capture method '${response.body.capture_method}' (expected one of ${CAPTURE_METHODS.join(', ')})`);\n}","handlingStrategy":"type-guard","validationCode":"const CAPTURE_METHODS = ['automatic', 'manual', 'manual_multiple'];\nif (!CAPTURE_METHODS.includes(capture_method)) {\n  throw new Error(`Unsupported capture_method '${capture_method}' — expected ${CAPTURE_METHODS.join('|')}`);\n}","typeGuard":"const isKnownCaptureMethod = (v) =>\n  typeof v === 'string' && ['automatic', 'manual', 'manual_multiple'].includes(v);","tryCatchPattern":null,"preventionTips":["Centralize capture/auth enum lists instead of chained literals","Diff enum sets on every backend upgrade","Confirm the create-intent step accepted the capture_method rather than defaulting it"],"tags":["cypress","hyperswitch","payments","enum-drift","capture-method"],"backgroundTag":null,"analyzedSha":"9b8b89dc378b62c9a6feda647bad4719d2de7699","analyzedAt":"2026-08-16T09:01:53.433Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}