juspay/hyperswitch · error · Error

Business Profile call failed ${response.body.error.message}

Error message

Business Profile call failed ${response.body.error.message}

What it means

Thrown by the createBusinessProfileTest Cypress command (cypress-tests/cypress/support/commands.js:950) when POST {baseUrl}/account/{merchantId}/business_profile returns a non-200 status while the test expected success (expectedStatus === 200). The thrown text embeds the server's own response.body.error.message, so what you see is the backend's rejection reason. Because the throw happens inside a cy.wrap(...).then() chain, it fails the Cypress test immediately.

Source

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

              }
              if (reqWebhook.refund_statuses_enabled) {
                expect(respWebhook.refund_statuses_enabled).to.deep.equal(
                  reqWebhook.refund_statuses_enabled
                );
              }
              if (reqWebhook.payout_statuses_enabled) {
                expect(respWebhook.payout_statuses_enabled).to.deep.equal(
                  reqWebhook.payout_statuses_enabled
                );
              }
              if (reqWebhook.payment_failed_enabled !== undefined) {
                expect(respWebhook.payment_failed_enabled).to.equal(
                  reqWebhook.payment_failed_enabled
                );
              }
            }
          } else {
            throw new Error(
              `Business Profile call failed ${response.body.error.message}`
            );
          }
        } else {
          expect(response.status).to.equal(expectedStatus);
          expect(response.body.error).to.exist;
        }
      });
    });
  }
);

Cypress.Commands.add(
  "pollStatusCallTest",
  (pollId, data, globalState, usePublishableKey = true) => {
    const { Response: resData } = data || {};

    const apiKey = usePublishableKey

View on GitHub (pinned to 9b8b89dc37)

Solutions

  1. Read the embedded server message and the x-request-id logged just above the throw, then search the Hyperswitch app logs for that request id
  2. Verify prerequisites: globalState.get('apiKey') and globalState.get('merchantId') must have been set by earlier steps in THIS run (dump via cy.task('getGlobalState'))
  3. Confirm baseUrl targets the intended environment and its API version matches the request body schema
  4. For negative tests, pass the expected failure status explicitly (4th argument) instead of relying on the 200 default
  5. If the status was 5xx, re-run once the target environment is healthy

Example fix

// before — negative test relies on default expectedStatus=200 and throws
cy.createBusinessProfileTest(badBody, globalState);
// after — assert the intended validation failure
cy.createBusinessProfileTest(badBody, globalState, 'profile', 400);
Defensive patterns

Strategy: try-catch

Validate before calling

if (!globalState.get('apiKey') || !globalState.get('merchantId')) {
  throw new Error('createBusinessProfileTest prerequisites missing: run merchant + api-key setup first');
}

Try / catch

// Cypress command failures are not catchable at the call site; intercept per-test
it('creates business profile', () => {
  cy.on('fail', (err) => {
    if (err.message.includes('Business Profile call failed')) {
      throw new Error(`PREREQ FAILED — check apiKey/merchantId/baseUrl: ${err.message}`);
    }
    throw err;
  });
  cy.createBusinessProfileTest(body, globalState);
});

Prevention

When it happens

Trigger: Calling cy.createBusinessProfileTest(body, globalState) with the default expectedStatus=200 and the API answering 401 (stale/rotated merchant api-key in globalState), 404 (merchantId not found), 400 (invalid webhook_details fields such as payment_statuses_enabled/payout_statuses_enabled or an invalid generated profile_name), or a 5xx from the business-profile service.

Common situations: Prerequisite steps (merchant create, api-key create) failed or were skipped so globalState holds a stale apiKey/merchantId; baseUrl points at an environment running a different Hyperswitch version with a stricter profile schema; specs executed out of order (grep/tag filtering) so profile creation runs before setup; transient 5xx during a deploy.

Related errors


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