juspay/hyperswitch · error · Error
Please provide a baseUrl
Error message
Please provide a baseUrl
What it means
Thrown by validateEnv(baseUrl, keyIdType) in cypress-tests-v2/cypress/utils/RequestBodyUtils.js when the baseUrl argument is falsy. The function maps a base URL to the API key prefix used in request bodies (keyPrefixes covers localhost/integ/sandbox), so it refuses to run with no URL at all.
Source
Thrown at cypress-tests-v2/cypress/utils/RequestBodyUtils.js:30
key_id: "snd_",
},
};
export function isoTimeTomorrow() {
const now = new Date();
// Create a new date object for tomorrow
const tomorrow = new Date(now);
tomorrow.setDate(now.getDate() + 1);
// Convert to ISO string format
const isoStringTomorrow = tomorrow.toISOString();
return isoStringTomorrow;
}
export function validateEnv(baseUrl, keyIdType) {
if (!baseUrl) {
throw new Error("Please provide a baseUrl");
}
const environment = Object.keys(keyPrefixes).find((env) =>
baseUrl.includes(env)
);
if (!environment) {
throw new Error("Unsupported baseUrl");
}
const prefix = keyPrefixes[environment][keyIdType];
if (!prefix) {
throw new Error(`Unsupported keyIdType: ${keyIdType}`);
}
return prefix;
}View on GitHub (pinned to 9b8b89dc37)
Solutions
- Pass a real baseUrl, e.g. --env baseUrl=https://sandbox.hyperswitch.io when launching Cypress
- Set the env in cypress.config / the CI environment so Cypress.env('baseUrl') resolves before tests call validateEnv
- Fail fast at spec start with a clear message listing the missing env instead of deep inside request-body building
Example fix
// before
const prefix = validateEnv(Cypress.env('baseUrl'), 'publishable_key');
// after
const baseUrl = Cypress.env('baseUrl');
if (!baseUrl) throw new Error('Set CYPRESS_baseUrl (e.g. --env baseUrl=https://sandbox.hyperswitch.io)');
const prefix = validateEnv(baseUrl, 'publishable_key'); Defensive patterns
Strategy: validation
Validate before calling
// At spec bootstrap, fail fast with all missing envs
const baseUrl = Cypress.env('baseUrl');
if (!baseUrl) {
throw new Error(
`Missing baseUrl. Start cypress with --env baseUrl=https://sandbox.hyperswitch.io (env keys present: ${Object.keys(Cypress.env()).join(', ')})`
);
} Prevention
- Centralize env validation in support/e2e.js so it fails before tests, not inside request builders
- Print available Cypress.env() keys in bootstrap errors to spot naming typos
- CI: make the baseUrl env a required pipeline variable
When it happens
Trigger: Calling validateEnv('') , validateEnv(undefined) or validateEnv(null) — typically because the Cypress env that should hold the environment base URL (e.g. Cypress.env('baseUrl') or a BASE_URL variable) was never set for the run.
Common situations: Running cypress-tests-v2 without the required --env flags or without the env block in config; CI pipeline that injects the URL only for some jobs; typo in the env variable name so it reads undefined.
Related errors
- Unsupported baseUrl
- Unsupported keyIdType: ${keyIdType}
- Invalid config: missing path
- Missing proxyHttp or proxyHttps in globalState. globalState.
- Missing connectorId or methodFlow in globalState
AI-assisted analysis of juspay/hyperswitch@9b8b89dc37 (2026-08-16).
Data as JSON: /api/errors/a030b892d75c3a8d.
Report an issue: GitHub.