juspay/hyperswitch · error · Error
Unsupported keyIdType: ${keyIdType}
Error message
Unsupported keyIdType: ${keyIdType} What it means
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.
Source
Thrown at cypress-tests-v2/cypress/utils/RequestBodyUtils.js:44
}
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 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
Example fix
// before
const prefix = validateEnv(baseUrl, keyType); // keyType === 'publishable'
// after
const KEY_ID_TYPES = ['publishable_key', 'key_id'];
if (!KEY_ID_TYPES.includes(keyType)) {
throw new Error(`keyIdType must be one of ${KEY_ID_TYPES.join(', ')} (got ${keyType})`);
}
const prefix = validateEnv(baseUrl, keyType); Defensive patterns
Strategy: validation
Validate before calling
const KEY_ID_TYPES = ['publishable_key', 'key_id'];
if (!KEY_ID_TYPES.includes(keyIdType)) {
throw new Error(`keyIdType must be one of: ${KEY_ID_TYPES.join(', ')} (got: ${keyIdType})`);
}
const prefix = validateEnv(baseUrl, keyIdType); Type guard
/** @param {unknown} t @returns {t is 'publishable_key' | 'key_id'} */
function isKeyIdType(t) {
return t === 'publishable_key' || t === 'key_id';
} Prevention
- 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
When it happens
Trigger: Calling validateEnv(url, 'publishable') (truncated name), 'publishableKey' (camelCase), 'api_key', or undefined — the lookup returns undefined and the error names the exact input.
Common situations: 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.
Related errors
- Please provide a baseUrl
- Unsupported baseUrl
- Invalid config: missing path
- Missing connectorId or methodFlow in globalState
- computeHmac: 'key' and 'message' are required (got key=${!!k
AI-assisted analysis of juspay/hyperswitch@9b8b89dc37 (2026-08-16).
Data as JSON: /api/errors/11ac21fee5c71668.
Report an issue: GitHub.