{"record":{"id":"8731a81f32365127","repo":"calcom/cal.diy","slug":"event-type-with-id-eventtypeid-not-found-8731a8","errorCode":null,"errorMessage":"Event type with id ${eventTypeId} not found","messagePattern":"Event type with id (.+?) not found","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"apps/api/v2/src/platform/event-types/event-types_2024_06_14/controllers/event-types.controller.ts","lineNumber":133,"sourceCode":"    \n    Access control: This endpoint fetches an event type by ID and returns it only if the authenticated user is authorized. Authorization is granted to:\n    - System admins\n    - The event type owner\n    - Hosts of the event type or users assigned to the event type\n    - Team admins/owners of the team that owns the team event type\n    - Organization admins/owners of the event type owner's organization\n    - Organization admins/owners of the team's parent organization\n\n    Note: Update and delete endpoints remain restricted to the event type owner only.`,\n  })\n  async getEventTypeById(\n    @Param(\"eventTypeId\") eventTypeId: string,\n    @GetUser() user: ApiAuthGuardUser\n  ): Promise<GetEventTypeOutput_2024_06_14> {\n    const eventType = await this.eventTypesService.getEventTypeByIdIfAuthorized(user, Number(eventTypeId));\n\n    if (!eventType) {\n      throw new NotFoundException(`Event type with id ${eventTypeId} not found`);\n    }\n\n    const responseEventType = this.isTeamEventType(eventType)\n      ? await this.outputTeamEventTypesResponsePipe.transform(eventType)\n      : this.eventTypeResponseTransformPipe.transform(eventType);\n\n    return {\n      status: SUCCESS_STATUS,\n      data: responseEventType,\n    };\n  }\n\n  private isTeamEventType(\n    eventType: DatabaseTeamEventType | ({ ownerId: number } & DatabaseEventType)\n  ): eventType is DatabaseTeamEventType {\n    return !!eventType.teamId;\n  }\n","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/event-types/event-types_2024_06_14/controllers/event-types.controller.ts#L115-L151","documentation":"Thrown by EventTypesController_2024_06_14.getEventTypeById (GET /v2/event-types/:eventTypeId with cal-api-version 2024-06-14) when eventTypesService.getEventTypeByIdIfAuthorized returns null. Null means the event type does not exist OR the authenticated user lacks access (not owner, host, team admin, or org admin). The controller conflates the two into a single 404 to avoid leaking existence.","triggerScenarios":"GET /v2/event-types/999 with a non-existent id; GET for an event type where the user is not the owner, not a host, not a team admin of the owning team, and not an org admin of the owning org; the id exists but is a team event type the user cannot see.","commonSituations":"Cross-tenant access attempts; a user freshly added to a team before propagation; an event type moved to a different org; using a personal token to read a team event type the user is not a host of.","solutions":["Confirm the authenticated user is the owner, a host, a team admin, or an org admin of the event type.","List event types via GET /v2/event-types (which only returns authorized ones) and use an id from that set.","For team event types, verify the user's team membership and role.","If access should be granted, check the EventTypeAccessService rules and the user's memberships."],"exampleFix":"// before\nconst et = await api.get(`/v2/event-types/${id}`, { headers: { 'cal-api-version': '2024-06-14' } });\n// after\nconst visible = (await api.get('/v2/event-types', { headers: { 'cal-api-version': '2024-06-14' } })).data;\nif (!visible.some(e => e.id === id)) throw new Error('no access to event type');\nconst et = await api.get(`/v2/event-types/${id}`, { headers: { 'cal-api-version': '2024-06-14' } });","handlingStrategy":"validation","validationCode":"// Confirm the authenticated user can see the event type via the scoped list\nconst visible = (await api.get('/v2/event-types', { headers: { 'cal-api-version': '2024-06-14' } })).data ?? [];\nif (!visible.some((e) => e.id === eventTypeId)) {\n  throw new Error(`no authorized access to event type ${eventTypeId}`);\n}","typeGuard":"function isAuthorizedId(list: unknown, id: number): boolean {\n  return Array.isArray(list) && list.some((e) => typeof e === 'object' && e !== null && (e as any).id === id);\n}","tryCatchPattern":"try {\n  return await api.get(`/v2/event-types/${id}`, { headers: { 'cal-api-version': '2024-06-14' } });\n} catch (e) {\n  if (e.response?.status === 404) {\n    // not found OR not authorized — prompt re-auth or pick from the visible list\n  } else throw e;\n}","preventionTips":["Always send cal-api-version: 2024-06-14 to hit the broader authorization rules.","Source ids from GET /v2/event-types so they are guaranteed authorized.","For team event types, verify team membership and admin role in the org console."],"tags":["nestjs","not-found","event-types","authorization","cal-api-version"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}