{"record":{"id":"cdd0979ea51bcbf5","repo":"calcom/cal.diy","slug":"event-type-with-id-eventtypeid-not-found-cdd097","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/modules/event-types/guards/event-type-ownership.guard.ts","lineNumber":37,"sourceCode":"    const user = request.user as ApiAuthGuardUser | undefined;\n    const eventTypeIdParam = request.params?.eventTypeId;\n\n    if (!user) {\n      throw new ForbiddenException(\"EventTypeOwnershipGuard - No user associated with the request.\");\n    }\n\n    if (!eventTypeIdParam) {\n      throw new BadRequestException(\"Missing eventTypeId param.\");\n    }\n\n    const eventTypeId = Number(eventTypeIdParam);\n    if (!Number.isInteger(eventTypeId) || eventTypeId <= 0) {\n      throw new BadRequestException(\"Invalid eventTypeId param.\");\n    }\n    const eventType = await this.eventTypesService.getUserEventType(user.id, eventTypeId);\n    if (!eventType) {\n      // Mirrors EventTypesService behavior: NotFound when not owned or not present\n      throw new NotFoundException(`Event type with id ${eventTypeId} not found`);\n    }\n\n    return true;\n  }\n}\n","sourceCodeStart":19,"sourceCodeEnd":43,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/event-types/guards/event-type-ownership.guard.ts#L19-L43","documentation":"Thrown by EventTypeOwnershipGuard.canActivate when eventTypesService.getUserEventType(user.id, eventTypeId) returns a falsy result. getUserEventType scopes the query to the requesting user, so this fires both when the event type does not exist AND when it exists but is not owned by the user. Raised as NotFoundException (HTTP 404) to avoid leaking existence of other users' resources (the comment notes this mirrors EventTypesService behavior).","triggerScenarios":"Client requests, updates, or deletes an eventTypeId that does not exist or belongs to a different user/owner. The ownership-scoped query returns nothing and the guard throws before the handler runs.","commonSituations":"Stale id from a deleted event type; cross-tenant access attempt; user switched accounts and the id belongs to the previous account; frontend cached an id after it was reassigned.","solutions":["Re-fetch the user's event types to obtain a current id they own.","Confirm the authenticated user is the owner (or has team membership granting access) of that event type.","Handle 404 gracefully in the client by refreshing the list and clearing stale references."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const owned = await eventTypesService.getUserEventType(user.id, eventTypeId);\nif (!owned) {\n  // refresh list, pick a valid id, or return 404 early\n}","typeGuard":null,"tryCatchPattern":"try {\n  await eventTypesController.update(eventTypeId, body);\n} catch (e) {\n  if (e instanceof NotFoundException && /not found/.test(e.message)) {\n    // refresh the list, drop stale id\n  }\n  throw e;\n}","preventionTips":["Refresh event-type lists after create/delete to avoid stale ids.","Confirm the requesting user is the owner before acting.","Handle 404 in the client by clearing cached ids."],"tags":["event-types","guard","ownership","not-found","authorization","nestjs"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}