{"record":{"id":"11ac21fee5c71668","repo":"juspay/hyperswitch","slug":"unsupported-keyidtype-keyidtype","errorCode":null,"errorMessage":"Unsupported keyIdType: ${keyIdType}","messagePattern":"Unsupported keyIdType: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cypress-tests-v2/cypress/utils/RequestBodyUtils.js","lineNumber":44,"sourceCode":"}\n\nexport function validateEnv(baseUrl, keyIdType) {\n  if (!baseUrl) {\n    throw new Error(\"Please provide a baseUrl\");\n  }\n\n  const environment = Object.keys(keyPrefixes).find((env) =>\n    baseUrl.includes(env)\n  );\n\n  if (!environment) {\n    throw new Error(\"Unsupported baseUrl\");\n  }\n\n  const prefix = keyPrefixes[environment][keyIdType];\n\n  if (!prefix) {\n    throw new Error(`Unsupported keyIdType: ${keyIdType}`);\n  }\n\n  return prefix;\n}\n","sourceCodeStart":26,"sourceCodeEnd":49,"githubUrl":"https://github.com/juspay/hyperswitch/blob/9b8b89dc378b62c9a6feda647bad4719d2de7699/cypress-tests-v2/cypress/utils/RequestBodyUtils.js#L26-L49","documentation":"Thrown by validateEnv in RequestBodyUtils when the baseUrl matched an environment but keyPrefixes[environment][keyIdType] is undefined. Only two keyIdType values are supported per environment: 'publishable_key' and 'key_id'; anything else (or a typo) throws with the offending value in the message.","triggerScenarios":"Calling validateEnv(url, 'publishable') (truncated name), 'publishableKey' (camelCase), 'api_key', or undefined — the lookup returns undefined and the error names the exact input.","commonSituations":"Renaming the key id type on the app side without updating test utils; passing a config field that is optional and therefore undefined in some specs; copy-paste between suites that used different key types.","solutions":["Pass exactly 'publishable_key' or 'key_id' as keyIdType","Check the value at the call site: log keyIdType before validateEnv to spot undefined/typo'd values","If a new key type is genuinely needed, add it under each environment in keyPrefixes"],"exampleFix":"// before\nconst prefix = validateEnv(baseUrl, keyType); // keyType === 'publishable'\n\n// after\nconst KEY_ID_TYPES = ['publishable_key', 'key_id'];\nif (!KEY_ID_TYPES.includes(keyType)) {\n  throw new Error(`keyIdType must be one of ${KEY_ID_TYPES.join(', ')} (got ${keyType})`);\n}\nconst prefix = validateEnv(baseUrl, keyType);","handlingStrategy":"validation","validationCode":"const KEY_ID_TYPES = ['publishable_key', 'key_id'];\nif (!KEY_ID_TYPES.includes(keyIdType)) {\n  throw new Error(`keyIdType must be one of: ${KEY_ID_TYPES.join(', ')} (got: ${keyIdType})`);\n}\nconst prefix = validateEnv(baseUrl, keyIdType);","typeGuard":"/** @param {unknown} t @returns {t is 'publishable_key' | 'key_id'} */\nfunction isKeyIdType(t) {\n  return t === 'publishable_key' || t === 'key_id';\n}","tryCatchPattern":null,"preventionTips":["Use exactly 'publishable_key' or 'key_id' — no camelCase variants","Log the keyIdType at the call site when it comes from config; undefined usually means an unset optional field","Add new key types to keyPrefixes under every environment when they are introduced"],"tags":["cypress","configuration","api-key","validation"],"backgroundTag":null,"analyzedSha":"9b8b89dc378b62c9a6feda647bad4719d2de7699","analyzedAt":"2026-08-16T09:01:53.433Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}