{"record":{"id":"a4525eb4595a3c96","repo":"juspay/hyperswitch","slug":"unsupported-baseurl","errorCode":null,"errorMessage":"Unsupported baseUrl","messagePattern":"Unsupported baseUrl","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cypress-tests-v2/cypress/utils/RequestBodyUtils.js","lineNumber":38,"sourceCode":"  const tomorrow = new Date(now);\n  tomorrow.setDate(now.getDate() + 1);\n\n  // Convert to ISO string format\n  const isoStringTomorrow = tomorrow.toISOString();\n  return isoStringTomorrow;\n}\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":20,"sourceCodeEnd":49,"githubUrl":"https://github.com/juspay/hyperswitch/blob/9b8b89dc378b62c9a6feda647bad4719d2de7699/cypress-tests-v2/cypress/utils/RequestBodyUtils.js#L20-L49","documentation":"Thrown by validateEnv in RequestBodyUtils when baseUrl is non-empty but does not contain any key of keyPrefixes as a substring — the map only knows 'localhost', 'integ' and 'sandbox'. The substring match (baseUrl.includes(env)) is crude, so any other hostname fails, including perfectly valid production-style URLs.","triggerScenarios":"Calling validateEnv('https://api.hyperswitch.io', ...) (no known substring), or a custom CI hostname like 'https://router.staging.internal:8080' where none of localhost/integ/sandbox appear in the URL.","commonSituations":"Pointing the suite at a new/private environment; a URL rewrite/proxy that hides the environment token; renaming environments without updating keyPrefixes; using 'integration' in the URL which does NOT contain 'integ' as substring... note 'integration' does contain 'integ', but e.g. 'prod' or 'staging' does not.","solutions":["Use a baseUrl that literally contains one of: localhost, integ, sandbox (e.g. https://sandbox.hyperswitch.io)","If the environment is legitimate, add its substring and key prefixes to keyPrefixes in RequestBodyUtils.js","For local runs, prefer http://localhost:8080 so the existing 'localhost' entry matches"],"exampleFix":"// before (keyPrefixes only knows localhost / integ / sandbox)\nconst keyPrefixes = {\n  localhost: { publishable_key: 'pk_dev_', key_id: 'dev_' },\n  integ: { publishable_key: 'pk_snd_', key_id: 'snd_' },\n  sandbox: { publishable_key: 'pk_snd_', key_id: 'snd_' },\n};\n\n// after (teach it the new environment)\nconst keyPrefixes = {\n  localhost: { publishable_key: 'pk_dev_', key_id: 'dev_' },\n  integ: { publishable_key: 'pk_snd_', key_id: 'snd_' },\n  sandbox: { publishable_key: 'pk_snd_', key_id: 'snd_' },\n  staging: { publishable_key: 'pk_stg_', key_id: 'stg_' },\n};","handlingStrategy":"validation","validationCode":"const KNOWN_ENVS = ['localhost', 'integ', 'sandbox'];\nconst baseUrl = Cypress.env('baseUrl');\nif (!KNOWN_ENVS.some((env) => baseUrl.includes(env))) {\n  throw new Error(\n    `baseUrl must contain one of ${KNOWN_ENVS.join(', ')} (got ${baseUrl}). Add the environment to keyPrefixes if it is legitimate.`\n  );\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep environment tokens in hostnames so substring routing keeps working (e.g. sandbox.example.com)","When onboarding a new environment, update keyPrefixes in RequestBodyUtils.js in the same change","Remember the check is substring-based: a URL that does not contain localhost/integ/sandbox will never match"],"tags":["cypress","configuration","environment","validation"],"backgroundTag":null,"analyzedSha":"9b8b89dc378b62c9a6feda647bad4719d2de7699","analyzedAt":"2026-08-16T09:01:53.433Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}