{"record":{"id":"66462be0f620968f","repo":"juspay/hyperswitch","slug":"missing-merchantid-adminapikey-or-baseurl-in-glo","errorCode":null,"errorMessage":"Missing merchantId, adminApiKey, or baseUrl in globalState","messagePattern":"Missing merchantId, adminApiKey, or baseUrl in globalState","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cypress-tests/cypress/support/commands.js","lineNumber":267,"sourceCode":"      `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\")}`\n    );\n  }\n\n  if (!connector || !methodFlowInput) {\n    throw new Error(\"Missing connectorId or methodFlow in globalState\");\n  }\n\n  if (!globalState) {\n    throw new Error(\"Missing required parameter: globalState\");\n  }\n\n  // --- Phase 2: Data Preparation ---\n  const merchantId = globalState.get(\"merchantId\");\n  const adminApiKey = globalState.get(\"adminApiKey\");\n  const baseUrl = globalState.get(\"baseUrl\");\n\n  if (!merchantId || !adminApiKey || !baseUrl) {\n    throw new Error(\n      \"Missing merchantId, adminApiKey, or baseUrl in globalState\"\n    );\n  }\n\n  const methodFlows = parseMethodFlows(methodFlowInput);\n\n  return cy\n    .task(\n      \"cli_log\",\n      `Creating ${type} rollout config for merchant: ${merchantId}`\n    )\n    .then(() => {\n      return cy\n        .task(\n          \"cli_log\",\n          `Processing ${methodFlows.length} flows: ${methodFlows.join(\", \")}`\n        )\n        .then(() => {","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/juspay/hyperswitch/blob/9b8b89dc378b62c9a6feda647bad4719d2de7699/cypress-tests/cypress/support/commands.js#L249-L285","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the suite's merchant-creation/setup hook runs before UCS config creation and stores merchantId, adminApiKey and baseUrl into globalState","Run via the normal runner/CI entrypoint that performs bootstrap instead of --spec on an individual file","Check Cypress env for the admin API key when it is sourced from env rather than creation","Log globalState keys before the throw site to see which of the three is missing"],"exampleFix":"// before\nbeforeEach(() => {\n  createUcsUppConfig(globalState, 'rollout'); // merchantId never set\n});\n\n// after\nbefore(() => {\n  cy.createMerchantTest().then(() => {\n    // stores merchantId, adminApiKey, baseUrl in globalState\n  });\n});\nbeforeEach(() => {\n  createUcsUppConfig(globalState, 'rollout');\n});","handlingStrategy":"validation","validationCode":"// Before createUcsConfigs\nconst merchantId = globalState.get('merchantId');\nconst adminApiKey = globalState.get('adminApiKey');\nconst baseUrl = globalState.get('baseUrl');\nif (!merchantId || !adminApiKey || !baseUrl) {\n  throw new Error(\n    `UCS prerequisites missing: merchantId=${!!merchantId}, adminApiKey=${!!adminApiKey}, baseUrl=${!!baseUrl}. Run the merchant bootstrap first.`\n  );\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guarantee the merchant-creation hook runs before any UCS command (ordered before/beforeEach)","Run the full runner/CI entrypoint so bootstrap executes; avoid bare --spec retries of UCS suites","Log globalState keys in setup failures to spot reset/rename issues quickly"],"tags":["cypress","ucs","credentials","global-state","test-infrastructure"],"backgroundTag":null,"analyzedSha":"9b8b89dc378b62c9a6feda647bad4719d2de7699","analyzedAt":"2026-08-16T09:01:53.433Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}