{"record":{"id":"f9f05ed679ffd8ba","repo":"juspay/hyperswitch","slug":"computehmac-key-and-message-are-required-got","errorCode":null,"errorMessage":"computeHmac: 'key' and 'message' are required (got key=${!!key}, message=${!!message})","messagePattern":"computeHmac: 'key' and 'message' are required \\(got key=(.+?), message=(.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cypress-tests/cypress.config.js","lineNumber":68,"sourceCode":"        },\n        readFileOrNull: (filePath) => {\n          if (!fs.existsSync(filePath)) return null;\n          try {\n            return JSON.parse(fs.readFileSync(filePath, \"utf8\"));\n          } catch {\n            return null;\n          }\n        },\n        cli_log: (message) => {\n          // eslint-disable-next-line no-console\n          console.log(\"Logging console message from task\");\n          // eslint-disable-next-line no-console\n          console.log(message);\n          return null;\n        },\n        computeHmac: ({ key, message, algorithm = \"sha512\" }) => {\n          if (!key || !message) {\n            throw new Error(\n              `computeHmac: 'key' and 'message' are required (got key=${!!key}, message=${!!message})`\n            );\n          }\n          const signature = crypto\n            .createHmac(algorithm, key)\n            .update(message)\n            .digest(\"hex\");\n          return signature;\n        },\n      });\n      on(\"after:spec\", (spec, results) => {\n        // Clean up resources after each spec\n        if (\n          results &&\n          results.video &&\n          !results.tests.some((test) =>\n            test.attempts.some((attempt) => attempt.state === \"failed\")\n          )","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/juspay/hyperswitch/blob/9b8b89dc378b62c9a6feda647bad4719d2de7699/cypress-tests/cypress.config.js#L50-L86","documentation":"Thrown by the computeHmac Cypress task in cypress-tests/cypress.config.js when either key or message is falsy. The task wraps node crypto.createHmac (default sha512) to compute the HMAC signature header tests attach to requests (e.g. checkout/webhook signing); the guard rejects empty secrets or payloads before crypto gets garbage.","triggerScenarios":"cy.task('computeHmac', { key: Cypress.env('HMAC_KEY'), message: body }) where the HMAC secret env is unset (key undefined) or the message body is empty/undefined — the task throws with (got key=false, message=true)-style diagnostics.","commonSituations":"CI job missing the HMAC secret env var; local runs without the .env/bootstrap that provides signing keys; a spec computing a signature over an optional body that is undefined; empty-string secret after a bad env substitution.","solutions":["Set the HMAC key env var for the run (e.g. CYPRESS_HMAC_KEY or however the spec sources it) so key is non-empty","Ensure message is the serialized request body string — JSON.stringify it at the call site if needed","Search failing specs for cy.task('computeHmac' and check which argument is falsy per the (got key=..., message=...) hint in the message","Fail fast in support/setup code listing required envs before any test runs"],"exampleFix":"// before\ncy.task('computeHmac', {\n  key: Cypress.env('HMAC_KEY'),\n  message: undefined,\n});\n\n// after\nconst key = Cypress.env('HMAC_KEY');\nif (!key) throw new Error('HMAC_KEY env is required for signature computation');\ncy.task('computeHmac', { key, message: JSON.stringify(requestBody) });","handlingStrategy":"validation","validationCode":"// Before cy.task('computeHmac', ...)\nconst key = Cypress.env('HMAC_KEY');\nif (!key) throw new Error('HMAC_KEY env is required to sign requests');\nif (!message) throw new Error('computeHmac requires a non-empty message body');\ncy.task('computeHmac', { key, message });","typeGuard":null,"tryCatchPattern":"cy.task('computeHmac', { key, message }).then((sig) => sig, (err) => {\n  if (/computeHmac: 'key' and 'message' are required/.test(err.message)) {\n    throw new Error('Signing skipped: HMAC secret not configured for this environment');\n  }\n  throw err;\n});","preventionTips":["Fail fast in support setup listing all required secrets (HMAC key etc.) before specs run","Always JSON.stringify the payload at the call site so message is never undefined","Use the (got key=..., message=...) fragment in the message to identify which argument was empty"],"tags":["cypress","hmac","signature","configuration","test-infrastructure"],"backgroundTag":null,"analyzedSha":"9b8b89dc378b62c9a6feda647bad4719d2de7699","analyzedAt":"2026-08-16T09:01:53.433Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}