{"record":{"id":"9efddba2fdc2045b","repo":"juspay/hyperswitch","slug":"invalid-requesttype-requesttype","errorCode":null,"errorMessage":"Invalid requestType: ${requestType}","messagePattern":"Invalid requestType: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cypress-tests/cypress/support/commands.js","lineNumber":7612,"sourceCode":"    }\n  }\n);\n\nCypress.Commands.add(\"setConfigs\", (globalState, key, value, requestType) => {\n  if (!key || !requestType) {\n    throw new Error(\"Key and requestType are required parameters\");\n  }\n\n  const REQUEST_CONFIG = {\n    CREATE: { method: \"POST\", useKey: false },\n    UPDATE: { method: \"POST\", useKey: true },\n    FETCH: { method: \"GET\", useKey: true },\n    DELETE: { method: \"DELETE\", useKey: true },\n  };\n\n  const config = REQUEST_CONFIG[requestType];\n  if (!config) {\n    throw new Error(`Invalid requestType: ${requestType}`);\n  }\n\n  const apiKey = globalState.get(\"adminApiKey\");\n  const baseUrl = globalState.get(\"baseUrl\");\n  const url = `${baseUrl}/configs/${config.useKey ? key : \"\"}`;\n\n  const getRequestBody = {\n    CREATE: () => ({ key, value }),\n    UPDATE: () => ({ value }),\n  };\n  const body = getRequestBody[requestType]?.() || undefined;\n\n  cy.request({\n    method: config.method,\n    url,\n    headers: {\n      \"Content-Type\": \"application/json\",\n      \"api-key\": apiKey,","sourceCodeStart":7594,"sourceCodeEnd":7630,"githubUrl":"https://github.com/juspay/hyperswitch/blob/9b8b89dc378b62c9a6feda647bad4719d2de7699/cypress-tests/cypress/support/commands.js#L7594-L7630","documentation":"Thrown synchronously by setConfigs when requestType is present but not a key of REQUEST_CONFIG — only CREATE, UPDATE, FETCH, DELETE (uppercase) are accepted. The lookup REQUEST_CONFIG[requestType] returns undefined for anything else, including lowercase or misspelled variants.","triggerScenarios":"Passing 'create', 'Delete', 'PATCH', or a typo like 'CREAT' as requestType; interpolating requestType from a fixture whose value was never normalized to the uppercase enum.","commonSituations":"Fixture-driven request types with inconsistent casing; refactoring from string literals to constants and missing a call site; new operation type added to the API but not to REQUEST_CONFIG.","solutions":["Use exactly 'CREATE' | 'UPDATE' | 'FETCH' | 'DELETE' (uppercase) at every call site","Normalize fixture input: requestType = String(raw).toUpperCase() before calling setConfigs","If the admin API gained a new operation, add it to REQUEST_CONFIG plus the method/useKey/body entries"],"exampleFix":"// before\ncy.setConfigs(globalState, 'ucs_enabled', 'true', 'create');\n// after\ncy.setConfigs(globalState, 'ucs_enabled', 'true', 'CREATE');","handlingStrategy":"type-guard","validationCode":"// normalize before calling\nconst REQUEST_TYPES = ['CREATE', 'UPDATE', 'FETCH', 'DELETE'];\nconst normalized = String(rawRequestType ?? '').toUpperCase();\nif (!REQUEST_TYPES.includes(normalized)) {\n  throw new Error(`requestType must be one of ${REQUEST_TYPES.join('|')}`);\n}\ncy.setConfigs(globalState, key, value, normalized);","typeGuard":"const isRequestType = (v) =>\n  ['CREATE', 'UPDATE', 'FETCH', 'DELETE'].includes(v);","tryCatchPattern":null,"preventionTips":["Define a REQUEST_TYPES constant and use it for both validation and the REQUEST_CONFIG map","Never hand-type requestType strings at call sites — reference named constants","Normalize fixture-provided request types to uppercase before invoking setConfigs"],"tags":["cypress","configs","enum","validation"],"backgroundTag":null,"analyzedSha":"9b8b89dc378b62c9a6feda647bad4719d2de7699","analyzedAt":"2026-08-16T09:01:53.433Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}