{"record":{"id":"bb08aa0e2e4d9ff2","repo":"calcom/cal.diy","slug":"invalid-request-body","errorCode":null,"errorMessage":"Invalid request body","messagePattern":"Invalid request body","errorType":"http","errorClass":"HttpError","httpStatus":400,"severity":"warning","filePath":"packages/app-store/basecamp3/api/projectMutation.ts","lineNumber":28,"sourceCode":"import prisma from \"@calcom/prisma\";\nimport { credentialForCalendarServiceSelect } from \"@calcom/prisma/selects/credential\";\n\ninterface IDock {\n  id: number;\n  name: string;\n}\n\nconst ZProjectMutationInputSchema = z.object({ projectId: z.string() });\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 parsed = ZProjectMutationInputSchema.safeParse(req.body ?? {});\n  if (!parsed.success) {\n    throw new HttpError({\n      statusCode: 400,\n      message: \"Invalid request body\",\n    });\n  }\n  const { projectId } = parsed.data;\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;","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/packages/app-store/basecamp3/api/projectMutation.ts#L10-L46","documentation":"Thrown when ZProjectMutationInputSchema.safeParse(req.body) fails - the body must be { projectId: string }. A missing projectId, a non-string value, or an empty body triggers it. Surfaced as HTTP 400.","triggerScenarios":"POST with no body; projectId sent as a number instead of a string; wrong field name such as project_id; body sent as form-encoded instead of JSON.","commonSituations":"Frontend form bug omitting projectId; client serializing the field under a different key; missing Content-Type: application/json header.","solutions":["Send { projectId: '123' } (string) as a JSON body.","Validate on the client with the same Zod schema before posting.","Ensure the request sets Content-Type: application/json."],"exampleFix":"// before\nfetch('/api/integrations/basecamp3/project', { method: 'POST', body: JSON.stringify({ projectId: 123 }) });\n\n// after\nfetch('/api/integrations/basecamp3/project', {\n  method: 'POST',\n  headers: { 'Content-Type': 'application/json' },\n  body: JSON.stringify({ projectId: String(123) }),\n});","handlingStrategy":"validation","validationCode":"const parsed = ZProjectMutationInputSchema.safeParse(req.body ?? {});\nif (!parsed.success) {\n  // surface parsed.error.issues to the client for a clearer message\n}","typeGuard":"const isProjectIdBody = (b: unknown): b is { projectId: string } =>\n  typeof b === 'object' && b !== null && typeof (b as any).projectId === 'string';","tryCatchPattern":null,"preventionTips":["Validate the body with the same Zod schema on the client before posting.","Always send projectId as a string with Content-Type: application/json.","Reuse the exact field name 'projectId'."],"tags":["basecamp3","zod","validation","request-body"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}