juspay/hyperswitch · error · Error

Missing merchantId, adminApiKey, or baseUrl in globalState

Error message

Missing merchantId, adminApiKey, or baseUrl in globalState

What it means

Thrown by createUcsConfigs in cypress-support/commands.js (Phase 2: Data Preparation) when globalState is missing merchantId, adminApiKey or baseUrl. These are the credentials used by the cy.task calls that create the UCS rollout/shadow config against the router admin API; without them the config-creation requests cannot even be addressed.

Source

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

      `Missing proxyHttp or proxyHttps in globalState. globalState.proxyHttp=${httpUrl}, globalState.proxyHttps=${httpsUrl}, Cypress.env("PROXY_HTTP")=${Cypress.env("PROXY_HTTP")}, Cypress.env("PROXY_HTTPS")=${Cypress.env("PROXY_HTTPS")}`
    );
  }

  if (!connector || !methodFlowInput) {
    throw new Error("Missing connectorId or methodFlow in globalState");
  }

  if (!globalState) {
    throw new Error("Missing required parameter: globalState");
  }

  // --- Phase 2: Data Preparation ---
  const merchantId = globalState.get("merchantId");
  const adminApiKey = globalState.get("adminApiKey");
  const baseUrl = globalState.get("baseUrl");

  if (!merchantId || !adminApiKey || !baseUrl) {
    throw new Error(
      "Missing merchantId, adminApiKey, or baseUrl in globalState"
    );
  }

  const methodFlows = parseMethodFlows(methodFlowInput);

  return cy
    .task(
      "cli_log",
      `Creating ${type} rollout config for merchant: ${merchantId}`
    )
    .then(() => {
      return cy
        .task(
          "cli_log",
          `Processing ${methodFlows.length} flows: ${methodFlows.join(", ")}`
        )
        .then(() => {

View on GitHub (pinned to 9b8b89dc37)

Solutions

  1. Ensure the suite's merchant-creation/setup hook runs before UCS config creation and stores merchantId, adminApiKey and baseUrl into globalState
  2. Run via the normal runner/CI entrypoint that performs bootstrap instead of --spec on an individual file
  3. Check Cypress env for the admin API key when it is sourced from env rather than creation
  4. Log globalState keys before the throw site to see which of the three is missing

Example fix

// before
beforeEach(() => {
  createUcsUppConfig(globalState, 'rollout'); // merchantId never set
});

// after
before(() => {
  cy.createMerchantTest().then(() => {
    // stores merchantId, adminApiKey, baseUrl in globalState
  });
});
beforeEach(() => {
  createUcsUppConfig(globalState, 'rollout');
});
Defensive patterns

Strategy: validation

Validate before calling

// Before createUcsConfigs
const merchantId = globalState.get('merchantId');
const adminApiKey = globalState.get('adminApiKey');
const baseUrl = globalState.get('baseUrl');
if (!merchantId || !adminApiKey || !baseUrl) {
  throw new Error(
    `UCS prerequisites missing: merchantId=${!!merchantId}, adminApiKey=${!!adminApiKey}, baseUrl=${!!baseUrl}. Run the merchant bootstrap first.`
  );
}

Prevention

When it happens

Trigger: UCS config creation runs before the test's setup hooks populated globalState — e.g. a before() that creates the merchant account and stores merchantId/adminApiKey did not run (skipped hook, hook failure swallowed, or a support-file change), or the suite relies on env vars that were not injected.

Common situations: Retrying a single spec outside the full runner so merchant bootstrap never happened; global state reset between tests dropping credentials; parallelized runs where the setup spec runs on a different machine; renamed state keys after a refactor.

Related errors


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