juspay/hyperswitch · error · Error

Blocklist create rule failed with status: ${response.status}

Error message

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

What it means

Thrown by blocklistCreateRule when POST /blocklist (api-key auth, body type='card_bin', data=cardBin) responds non-200. On success the command asserts fingerprint_id === cardBin, data_kind === 'card_bin', and a non-null created_at; any failure status throws with the server's error message.

Source

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

        "api-key": apiKey,
      },
      body: body,
      failOnStatusCode: false,
    }).then((response) => {
      logRequestId(response.headers["x-request-id"]);

      cy.wrap(response).then(() => {
        if (response.status === 200) {
          expect(response.body)
            .to.have.property("fingerprint_id")
            .to.equal(cardBin);
          expect(response.body)
            .to.have.property("data_kind")
            .to.equal("card_bin");
          expect(response.body).to.have.property("created_at").to.not.be.null;
          globalState.set("blocklistRuleId", response.body.fingerprint_id);
        } else {
          throw new Error(
            `Blocklist create rule failed with status: ${response.status} and message: ${response.body?.error?.message}`
          );
        }
      });
    });
  }
);

Cypress.Commands.add("blocklistDeleteRule", (type, data, globalState) => {
  const apiKey = globalState.get("apiKey");
  const baseUrl = globalState.get("baseUrl");
  const url = `${baseUrl}/blocklist`;

  const body = {
    type: type,
    data: data,
  };

View on GitHub (pinned to 9b8b89dc37)

Solutions

  1. Delete the rule first in a before hook: cy.blocklistDeleteRule('card_bin', cardBin, globalState) — it is idempotent when tolerated
  2. Verify globalState.get('apiKey') is the correct key for the target baseUrl
  3. Check x-request-id in server logs for the exact rejection reason
  4. Confirm the blocklist feature is enabled for the environment

Example fix

// before
before(() => {
  cy.blocklistCreateRule(requestBody, cardBin, globalState);
});
// after
before(() => {
  cy.blocklistDeleteRule('card_bin', cardBin, globalState); // clear stale rule
  cy.blocklistCreateRule(requestBody, cardBin, globalState);
});
Defensive patterns

Strategy: validation

Validate before calling

// make creation idempotent: clear any stale rule first
cy.blocklistDeleteRule('card_bin', cardBin, globalState);
cy.blocklistCreateRule(requestBody, cardBin, globalState);

Try / catch

cy.wrap(null)
  .then(() => cy.blocklistCreateRule(requestBody, cardBin, globalState))
  .catch((e) => {
    if (/status: 409/.test(e.message)) {
      // rule already exists — delete and recreate once
      cy.blocklistDeleteRule('card_bin', cardBin, globalState);
      return cy.blocklistCreateRule(requestBody, cardBin, globalState);
    }
    throw e;
  });

Prevention

When it happens

Trigger: Re-creating a card_bin rule that already exists (duplicate/conflict); invalid or missing apiKey (401/403); malformed card bin value (400); blocklist feature disabled in the environment (404/501).

Common situations: Rerunning specs without cleanup, leaving the previous run's rule in place; wrong apiKey in globalState for this environment; feature flag for the blocklist API off in staging.

Related errors


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