{"record":{"id":"feef900e98a085f4","repo":"juspay/hyperswitch","slug":"blocklist-delete-failed-with-status-response-st","errorCode":null,"errorMessage":"Blocklist delete failed with status: ${response.status} and message: ${response.body?.error?.message}","messagePattern":"Blocklist delete failed with status: (.+?) and message: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cypress-tests/cypress/support/commands.js","lineNumber":7769,"sourceCode":"  };\n\n  cy.request({\n    method: \"DELETE\",\n    url: url,\n    headers: {\n      \"Content-Type\": \"application/json\",\n      \"api-key\": apiKey,\n    },\n    body: body,\n    failOnStatusCode: false,\n  }).then((response) => {\n    logRequestId(response.headers[\"x-request-id\"]);\n\n    cy.wrap(response).then(() => {\n      if (response.status === 200) {\n        cy.log(`Blocklist rule deleted for ${type}: ${data}`);\n      } else {\n        throw new Error(\n          `Blocklist delete failed with status: ${response.status} and message: ${response.body?.error?.message}`\n        );\n      }\n    });\n  });\n});\n\nCypress.Commands.add(\n  \"paymentsEligibilityCheck\",\n  (requestBody, data, globalState) => {\n    const { Request: reqData, Response: resData } = data || {};\n\n    const publishableKey = globalState.get(\"publishableKey\");\n    const baseUrl = globalState.get(\"baseUrl\");\n    const paymentId = globalState.get(\"paymentID\");\n    const clientSecret = globalState.get(\"clientSecret\");\n    const url = `${baseUrl}/payments/${paymentId}/eligibility`;\n","sourceCodeStart":7751,"sourceCodeEnd":7787,"githubUrl":"https://github.com/juspay/hyperswitch/blob/9b8b89dc378b62c9a6feda647bad4719d2de7699/cypress-tests/cypress/support/commands.js#L7751-L7787","documentation":"Thrown by blocklistDeleteRule when DELETE /blocklist (api-key auth, body {type, data}) responds non-200. The command logs success on 200 and throws otherwise, most commonly because the targeted rule does not exist (404) or the type/data pair does not match what was created.","triggerScenarios":"Deleting a card_bin rule that was never created or was already removed in the same run; type mismatch (deleting 'card_bin' when the rule was created under another data kind); invalid api key (401).","commonSituations":"after() hooks running delete when the before() create failed or was skipped; parallel specs racing to delete the same shared rule; cleanup invoked twice.","solutions":["Match the (type, data) pair exactly to the values used in blocklistCreateRule","Treat 404 as an acceptable idempotent outcome in cleanup hooks rather than a hard failure","Ensure the create step succeeded before the delete step runs","Verify apiKey and baseUrl are consistent between create and delete"],"exampleFix":"// before (commands.js)\nif (response.status === 200) {\n  cy.log(`Blocklist rule deleted for ${type}: ${data}`);\n} else {\n  throw new Error(`Blocklist delete failed ...`);\n}\n// after\nif (response.status === 200) {\n  cy.log(`Blocklist rule deleted for ${type}: ${data}`);\n} else if (response.status !== 404) {\n  throw new Error(`Blocklist delete failed ...`);\n} else {\n  cy.log(`Rule already absent for ${type}: ${data} (idempotent)`);\n}","handlingStrategy":"fallback","validationCode":"// only attempt delete when a rule plausibly exists\nif (globalState.get('blocklistRuleId')) {\n  cy.blocklistDeleteRule('card_bin', cardBin, globalState);\n}","typeGuard":null,"tryCatchPattern":"cy.wrap(null)\n  .then(() => cy.blocklistDeleteRule('card_bin', cardBin, globalState))\n  .catch((e) => {\n    if (/Blocklist delete failed with status: 404/.test(e.message)) {\n      cy.log('Rule already absent — treating delete as idempotent');\n      return null;\n    }\n    throw e;\n  });","preventionTips":["Treat blocklist delete as idempotent: 404 in an after() hook should not fail the spec","Always pass the identical (type, data) pair used at create time","Skip delete when blocklistRuleId was never set for this run"],"tags":["cypress","blocklist","cleanup","idempotency","http-error"],"backgroundTag":null,"analyzedSha":"9b8b89dc378b62c9a6feda647bad4719d2de7699","analyzedAt":"2026-08-16T09:01:53.433Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}