{"record":{"id":"fa28782d202ab6a8","repo":"calcom/cal.diy","slug":"unauthorized-fa2878","errorCode":null,"errorMessage":"Unauthorized","messagePattern":"Unauthorized","errorType":"http","errorClass":"HttpError","httpStatus":401,"severity":"warning","filePath":"packages/app-store/basecamp3/api/projects.ts","lineNumber":15,"sourceCode":"import type { NextApiRequest } from \"next\";\n\nimport getAppKeysFromSlug from \"@calcom/app-store/_utils/getAppKeysFromSlug\";\nimport { refreshAccessToken } from \"@calcom/app-store/basecamp3/lib/helpers\";\nimport type { BasecampToken } from \"@calcom/app-store/basecamp3/lib/types\";\nimport { defaultHandler } from \"@calcom/lib/server/defaultHandler\";\nimport { defaultResponder } from \"@calcom/lib/server/defaultResponder\";\nimport prisma from \"@calcom/prisma\";\nimport { credentialForCalendarServiceSelect } from \"@calcom/prisma/selects/credential\";\nimport { HttpError } from \"@calcom/lib/http-error\";\n\nasync function handler(req: NextApiRequest) {\n  const userId = req.session?.user?.id;\n  if (!userId) {\n    throw new HttpError({ statusCode: 401, message: \"Unauthorized\" });\n  }\n\n  const { user_agent } = await getAppKeysFromSlug(\"basecamp3\");\n\n  const credential = await prisma.credential.findFirst({\n    where: { userId },\n    select: credentialForCalendarServiceSelect,\n  });\n\n  if (!credential) {\n    throw new HttpError({ statusCode: 403, message: \"No credential found for user\" });\n  }\n\n  let credentialKey = credential.key as BasecampToken;\n\n  if (!credentialKey.account) {\n    return { currentProject: null, projects: [] };\n  }","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/packages/app-store/basecamp3/api/projects.ts#L1-L33","documentation":"Thrown by the Basecamp 3 projects listing handler (GET) when req.session.user.id is missing - the request has no authenticated Cal.com session. Surfaced as HTTP 401 via HttpError. Identical auth guard to the projectMutation endpoint.","triggerScenarios":"Unauthenticated GET to /api/basecamp3/projects; an expired session; direct URL access without login.","commonSituations":"Session timeout; opening the projects API URL directly in a browser tab without an active session; script fetching without cookies.","solutions":["Ensure the request includes a valid Cal.com session cookie.","Re-authenticate the user before retrying.","Drive the call from the authenticated in-app UI."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!req.session?.user?.id) {\n  // redirect to login or return 401\n}","typeGuard":"const isAuthenticated = (req: NextApiRequest): req is NextApiRequest & { session: { user: { id: number } } } =>\n  typeof req.session?.user?.id === 'number';","tryCatchPattern":null,"preventionTips":["Drive these calls from the authenticated in-app UI.","Handle 401 by redirecting to login.","Do not fetch the projects URL from unauthenticated scripts."],"tags":["basecamp3","auth","session","unauthorized"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}