{"record":{"id":"f401de77e2b7d409","repo":"juspay/hyperswitch","slug":"list-payment-methods-failed-with-status-code-re","errorCode":null,"errorMessage":"List payment methods failed with status code \"${response.status}\" and error message \"${response.body.error.message}\"","messagePattern":"List payment methods failed with status code \"(.+?)\" and error message \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cypress-tests/cypress/support/commands.js","lineNumber":2614,"sourceCode":"\n          Object.keys(expectedRequiredFields).forEach((key) => {\n            const expectedField = expectedRequiredFields[key];\n            const responseField = responseRequiredFields[key];\n\n            expect(responseField).to.exist;\n            expect(responseField.required_field).to.equal(\n              expectedField.required_field\n            );\n            expect(responseField.display_name).to.equal(\n              expectedField.display_name\n            );\n            expect(responseField.field_type).to.deep.equal(\n              expectedField.field_type\n            );\n            expect(responseField.value).to.equal(expectedField.value);\n          });\n        } else {\n          throw new Error(\n            `List payment methods failed with status code \"${response.status}\" and error message \"${response.body.error.message}\"`\n          );\n        }\n      });\n    });\n  }\n);\n\nCypress.Commands.add(\n  \"paymentMethodListTestTwoConnectorsForOnePaymentMethodCredit\",\n  (resData, globalState) => {\n    cy.request({\n      method: \"GET\",\n      url: `${globalState.get(\"baseUrl\")}/account/payment_methods?client_secret=${globalState.get(\"clientSecret\")}`,\n      headers: {\n        \"Content-Type\": \"application/json\",\n        Accept: \"application/json\",\n        \"api-key\": globalState.get(\"publishableKey\"),","sourceCodeStart":2596,"sourceCodeEnd":2632,"githubUrl":"https://github.com/juspay/hyperswitch/blob/9b8b89dc378b62c9a6feda647bad4719d2de7699/cypress-tests/cypress/support/commands.js#L2596-L2632","documentation":"Thrown by the paymentMethodListTestWithRequiredFields command (cypress-tests/cypress/support/commands.js:2614) when GET {baseUrl}/account/payment_methods?client_secret={clientSecret} returns non-200. The request authenticates with the publishableKey and the clientSecret stored in globalState by an earlier create-payment-intent step, so failures are almost always stale or missing state rather than a problem with the endpoint itself.","triggerScenarios":"clientSecret undefined because createPaymentIntentTest was not run or failed (400/401); publishableKey rotated so the api-key header is rejected; the intent behind the client_secret already consumed or expired; 5xx from the payments service.","commonSituations":"Reordered specs putting the payment-method list before intent creation; globalState reused across runs so the old clientSecret is dead; env mismatch between publishable key and baseUrl.","solutions":["Confirm the prerequisite createPaymentIntentTest ran and stored clientSecret (dump via cy.task('getGlobalState'))","Verify publishableKey belongs to the same environment as baseUrl","Check the client_secret isn't left over from a previous run's expired intent","Use the logged x-request-id to inspect server logs","Re-run the full flow fresh: intent creation then list"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const clientSecret = globalState.get('clientSecret');\nif (!clientSecret) {\n  throw new Error('clientSecret missing in globalState — run createPaymentIntentTest before listing payment methods');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never reuse clientSecret across runs — intents expire","Keep spec order: create intent before listing payment methods","Match publishableKey to the baseUrl environment"],"tags":["cypress","hyperswitch","payment-methods","client-secret","stale-state"],"backgroundTag":null,"analyzedSha":"9b8b89dc378b62c9a6feda647bad4719d2de7699","analyzedAt":"2026-08-16T09:01:53.433Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}