{"record":{"id":"48647722cbb6ab8b","repo":"juspay/hyperswitch","slug":"payment-method-delete-call-failed-with-error-messa","errorCode":null,"errorMessage":"Payment Method Delete Call Failed with error message: ${response.body.error.message}","messagePattern":"Payment Method Delete Call Failed with error message: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cypress-tests/cypress/support/commands.js","lineNumber":3102,"sourceCode":"    headers: {\n      Accept: \"application/json\",\n      \"api-key\": apiKey,\n    },\n    failOnStatusCode: false,\n  }).then((response) => {\n    logRequestId(response.headers[\"x-request-id\"]);\n\n    cy.wrap(response).then(() => {\n      expect(response.headers[\"content-type\"]).to.include(\"application/json\");\n      if (response.status === 200) {\n        expect(response.body.payment_method_id).to.equal(paymentMethodId);\n        expect(response.body.deleted).to.be.true;\n      } else if (response.status === 500 && baseUrl.includes(\"localhost\")) {\n        // delete payment method api endpoint requires tartarus (hyperswitch card vault) to be set up since it makes a call to the locker service to delete the payment method\n        expect(response.body.error.code).to.include(\"HE_00\");\n        expect(response.body.error.message).to.include(\"Something went wrong\");\n      } else {\n        throw new Error(\n          `Payment Method Delete Call Failed with error message: ${response.body.error.message}`\n        );\n      }\n    });\n  });\n});\n\nCypress.Commands.add(\"setDefaultPaymentMethodTest\", (globalState) => {\n  const payment_method_id = globalState.get(\"paymentMethodId\");\n  const customer_id = globalState.get(\"customerId\");\n\n  cy.request({\n    method: \"POST\",\n    url: `${globalState.get(\"baseUrl\")}/customers/${customer_id}/payment_methods/${payment_method_id}/default`,\n    headers: {\n      \"api-key\": globalState.get(\"apiKey\"),\n    },\n    failOnStatusCode: false,","sourceCodeStart":3084,"sourceCodeEnd":3120,"githubUrl":"https://github.com/juspay/hyperswitch/blob/9b8b89dc378b62c9a6feda647bad4719d2de7699/cypress-tests/cypress/support/commands.js#L3084-L3120","documentation":"Thrown by the deletePaymentMethodTest command (cypress-tests/cypress/support/commands.js:3102) when DELETE of a customer payment method returns non-200 outside the two accepted paths: 200 (deleted), or the localhost-only 500 whose error.code starts with HE_00 — deleting requires the tartarus (Hyperswitch card vault) locker service, and without it the call fails in a known way that the command tolerates on localhost. Any other status throws with the server message.","triggerScenarios":"paymentMethodId or customerId stale/missing in globalState so the DELETE targets a missing resource (404); the payment method already deleted by an earlier step; on a local environment, baseUrl not literally containing 'localhost' (e.g. 127.0.0.1 or a docker hostname) so the HE_00 exemption never applies; vault/locker service down in staging (non-HE_00 500); invalid api-key (401).","commonSituations":"Re-running delete steps against state whose payment method was already removed; local dev without tartarus but reaching the app via an IP or container name; vault outage in a shared environment.","solutions":["Identify the environment: if local without tartarus, make baseUrl literally include 'localhost' so the HE_00 branch applies ('127.0.0.1' will not match)","Verify paymentMethodId/customerId in globalState are fresh from this run's create step","If already deleted, remove the duplicate delete step","On non-local environments, check vault/locker service health when a 5xx appears","Correlate via the logged x-request-id"],"exampleFix":"// before — local env addressed by IP: the HE_00 exemption never triggers\nCypress.env('baseUrl', 'http://127.0.0.1:9090');\ncy.deletePaymentMethodTest(globalState);\n// after — use the hostname the command's check matches\ncy.deletePaymentMethodTest(globalState); // with baseUrl 'http://localhost:9090', the 500 HE_00 path is accepted","handlingStrategy":"validation","validationCode":"const pmId = globalState.get('paymentMethodId');\nif (!pmId) throw new Error('paymentMethodId missing — run the create-payment-method step first');\nconst isLocal = globalState.get('baseUrl').includes('localhost');\nif (isLocal) cy.task('cli_log', 'local run: without tartarus the 500 HE_00 path is expected');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 'localhost' (not 127.0.0.1 or a container name) in local baseUrl so the HE_00 exemption matches","Don't repeat delete steps across re-runs","Provision tartarus locally to exercise the real delete path"],"tags":["cypress","hyperswitch","payment-methods","vault","localhost"],"backgroundTag":null,"analyzedSha":"9b8b89dc378b62c9a6feda647bad4719d2de7699","analyzedAt":"2026-08-16T09:01:53.433Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}