juspay/hyperswitch · error · Error

Blocklist delete failed with status: ${response.status} and

Error message

Blocklist delete failed with status: ${response.status} and message: ${response.body?.error?.message}

What it means

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.

Source

Thrown at cypress-tests/cypress/support/commands.js:7769

  };

  cy.request({
    method: "DELETE",
    url: url,
    headers: {
      "Content-Type": "application/json",
      "api-key": apiKey,
    },
    body: body,
    failOnStatusCode: false,
  }).then((response) => {
    logRequestId(response.headers["x-request-id"]);

    cy.wrap(response).then(() => {
      if (response.status === 200) {
        cy.log(`Blocklist rule deleted for ${type}: ${data}`);
      } else {
        throw new Error(
          `Blocklist delete failed with status: ${response.status} and message: ${response.body?.error?.message}`
        );
      }
    });
  });
});

Cypress.Commands.add(
  "paymentsEligibilityCheck",
  (requestBody, data, globalState) => {
    const { Request: reqData, Response: resData } = data || {};

    const publishableKey = globalState.get("publishableKey");
    const baseUrl = globalState.get("baseUrl");
    const paymentId = globalState.get("paymentID");
    const clientSecret = globalState.get("clientSecret");
    const url = `${baseUrl}/payments/${paymentId}/eligibility`;

View on GitHub (pinned to 9b8b89dc37)

Solutions

  1. Match the (type, data) pair exactly to the values used in blocklistCreateRule
  2. Treat 404 as an acceptable idempotent outcome in cleanup hooks rather than a hard failure
  3. Ensure the create step succeeded before the delete step runs
  4. Verify apiKey and baseUrl are consistent between create and delete

Example fix

// before (commands.js)
if (response.status === 200) {
  cy.log(`Blocklist rule deleted for ${type}: ${data}`);
} else {
  throw new Error(`Blocklist delete failed ...`);
}
// after
if (response.status === 200) {
  cy.log(`Blocklist rule deleted for ${type}: ${data}`);
} else if (response.status !== 404) {
  throw new Error(`Blocklist delete failed ...`);
} else {
  cy.log(`Rule already absent for ${type}: ${data} (idempotent)`);
}
Defensive patterns

Strategy: fallback

Validate before calling

// only attempt delete when a rule plausibly exists
if (globalState.get('blocklistRuleId')) {
  cy.blocklistDeleteRule('card_bin', cardBin, globalState);
}

Try / catch

cy.wrap(null)
  .then(() => cy.blocklistDeleteRule('card_bin', cardBin, globalState))
  .catch((e) => {
    if (/Blocklist delete failed with status: 404/.test(e.message)) {
      cy.log('Rule already absent — treating delete as idempotent');
      return null;
    }
    throw e;
  });

Prevention

When it happens

Trigger: 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).

Common situations: after() hooks running delete when the before() create failed or was skipped; parallel specs racing to delete the same shared rule; cleanup invoked twice.

Related errors


AI-assisted analysis of juspay/hyperswitch@9b8b89dc37 (2026-08-16). Data as JSON: /api/errors/feef900e98a085f4. Report an issue: GitHub.