{"record":{"id":"f2158d059e9fe277","repo":"juspay/hyperswitch","slug":"business-profile-call-failed-response-body-error","errorCode":null,"errorMessage":"Business Profile call failed ${response.body.error.message}","messagePattern":"Business Profile call failed (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cypress-tests/cypress/support/commands.js","lineNumber":950,"sourceCode":"              }\n              if (reqWebhook.refund_statuses_enabled) {\n                expect(respWebhook.refund_statuses_enabled).to.deep.equal(\n                  reqWebhook.refund_statuses_enabled\n                );\n              }\n              if (reqWebhook.payout_statuses_enabled) {\n                expect(respWebhook.payout_statuses_enabled).to.deep.equal(\n                  reqWebhook.payout_statuses_enabled\n                );\n              }\n              if (reqWebhook.payment_failed_enabled !== undefined) {\n                expect(respWebhook.payment_failed_enabled).to.equal(\n                  reqWebhook.payment_failed_enabled\n                );\n              }\n            }\n          } else {\n            throw new Error(\n              `Business Profile call failed ${response.body.error.message}`\n            );\n          }\n        } else {\n          expect(response.status).to.equal(expectedStatus);\n          expect(response.body.error).to.exist;\n        }\n      });\n    });\n  }\n);\n\nCypress.Commands.add(\n  \"pollStatusCallTest\",\n  (pollId, data, globalState, usePublishableKey = true) => {\n    const { Response: resData } = data || {};\n\n    const apiKey = usePublishableKey","sourceCodeStart":932,"sourceCodeEnd":968,"githubUrl":"https://github.com/juspay/hyperswitch/blob/9b8b89dc378b62c9a6feda647bad4719d2de7699/cypress-tests/cypress/support/commands.js#L932-L968","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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","Verify prerequisites: globalState.get('apiKey') and globalState.get('merchantId') must have been set by earlier steps in THIS run (dump via cy.task('getGlobalState'))","Confirm baseUrl targets the intended environment and its API version matches the request body schema","For negative tests, pass the expected failure status explicitly (4th argument) instead of relying on the 200 default","If the status was 5xx, re-run once the target environment is healthy"],"exampleFix":"// before — negative test relies on default expectedStatus=200 and throws\ncy.createBusinessProfileTest(badBody, globalState);\n// after — assert the intended validation failure\ncy.createBusinessProfileTest(badBody, globalState, 'profile', 400);","handlingStrategy":"try-catch","validationCode":"if (!globalState.get('apiKey') || !globalState.get('merchantId')) {\n  throw new Error('createBusinessProfileTest prerequisites missing: run merchant + api-key setup first');\n}","typeGuard":null,"tryCatchPattern":"// Cypress command failures are not catchable at the call site; intercept per-test\nit('creates business profile', () => {\n  cy.on('fail', (err) => {\n    if (err.message.includes('Business Profile call failed')) {\n      throw new Error(`PREREQ FAILED — check apiKey/merchantId/baseUrl: ${err.message}`);\n    }\n    throw err;\n  });\n  cy.createBusinessProfileTest(body, globalState);\n});","preventionTips":["Dump globalState before this step to confirm apiKey and merchantId are fresh for this run","Order specs so profile creation always follows merchant/api-key setup","Pass expectedStatus explicitly for negative cases","Correlate failures with the x-request-id logged just before the throw"],"tags":["cypress","hyperswitch","business-profile","api-request","test-failure"],"backgroundTag":null,"analyzedSha":"9b8b89dc378b62c9a6feda647bad4719d2de7699","analyzedAt":"2026-08-16T09:01:53.433Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}