{"record":{"id":"bba05c765bf7fb82","repo":"calcom/cal.diy","slug":"unhandled-values","errorCode":null,"errorMessage":"Unhandled values","messagePattern":"Unhandled values","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"example-apps/credential-sync/pages/api/getToken.ts","lineNumber":29,"sourceCode":"      return res.status(403).json({ message: \"secret header not set\" });\n    }\n    if (secret !== CALCOM_CREDENTIAL_SYNC_SECRET) {\n      return res.status(403).json({ message: \"Invalid secret\" });\n    }\n\n    const calcomUserId = req.body.calcomUserId;\n    const appSlug = req.body.appSlug;\n    console.log(\"getToken Params\", {\n      calcomUserId,\n      appSlug,\n    });\n    let accessToken;\n    if (appSlug === \"google-calendar\") {\n      accessToken = await generateGoogleCalendarAccessToken();\n    } else if (appSlug === \"zoom\") {\n      accessToken = await generateZoomAccessToken();\n    } else {\n      throw new Error(\"Unhandled values\");\n    }\n    if (!accessToken) {\n      throw new Error(\"Unable to generate token\");\n    }\n    res.status(200).json({\n      _1: true,\n      access_token: accessToken,\n    });\n  } catch (e) {\n    res.status(500).json({ error: e.message });\n  }\n}\n","sourceCodeStart":11,"sourceCodeEnd":42,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/example-apps/credential-sync/pages/api/getToken.ts#L11-L42","documentation":"Thrown by the example credential-sync getToken endpoint when req.body.appSlug is neither 'google-calendar' nor 'zoom'. This is example/demo code showing how to build a credential sync server; it only implements two providers. The error is caught and returned as a 500 JSON body.","triggerScenarios":"POST to /api/getToken in the example credential-sync app with appSlug set to any value other than 'google-calendar' or 'zoom' (e.g. 'outlook', 'stripe', or undefined).","commonSituations":"Extending credential sync to a new provider without adding a branch; appSlug missing from the request body; typo in the slug; Cal.com requesting a token for an app the example server does not yet support.","solutions":["Add a branch for the new appSlug with its token-generation function in getToken.ts and the shared integrations lib.","Ensure the request body includes appSlug matching one of the supported values.","Copy this pattern into a real server and implement the providers you actually use."],"exampleFix":"// before\nif (appSlug === 'google-calendar') { ... }\nelse if (appSlug === 'zoom') { ... }\nelse { throw new Error('Unhandled values'); }\n// after\nconst generators: Record<string, () => Promise<string>> = {\n  'google-calendar': generateGoogleCalendarAccessToken,\n  'zoom': generateZoomAccessToken,\n  'microsoft-teams': generateTeamsAccessToken,\n};\nconst gen = generators[appSlug];\nif (!gen) throw new Error(`Unhandled appSlug: ${appSlug}`);\naccessToken = await gen();","handlingStrategy":"validation","validationCode":"const supported = ['google-calendar', 'zoom'];\nif (!supported.includes(appSlug)) {\n  return res.status(400).json({ error: `Unsupported appSlug '${appSlug}'. Supported: ${supported.join(', ')}` });\n}","typeGuard":"const SUPPORTED_SLUGS = ['google-calendar', 'zoom'] as const;\ntype SupportedSlug = typeof SUPPORTED_SLUGS[number];\nfunction isSupportedSlug(s: unknown): s is SupportedSlug {\n  return typeof s === 'string' && (SUPPORTED_SLUGS as readonly string[]).includes(s);\n}","tryCatchPattern":"null","preventionTips":["Validate appSlug against an explicit allowlist before branching.","When adding a provider, extend the allowlist and generator map together.","Return a descriptive error listing supported slugs for the caller."],"tags":["credential-sync","example-app","validation","oauth"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}