{"record":{"id":"d6e14ba240ab773c","repo":"calcom/cal.diy","slug":"event-type-with-slug-body-eventtypeslug-belongi-d6e14b","errorCode":null,"errorMessage":"Event type with slug ${body.eventTypeSlug} belonging to user ${body.username} within organization ${body.organizationSlug} not found.","messagePattern":"Event type with slug (.+?) belonging to user (.+?) within organization (.+?) not found\\.","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"apps/api/v2/src/platform/bookings/2024-08-13/services/errors.service.ts","lineNumber":17,"sourceCode":"import { BadRequestException, Injectable, NotFoundException } from \"@nestjs/common\";\nimport { Logger } from \"@nestjs/common\";\n\nimport { CreateBookingInput } from \"@calcom/platform-types\";\n\n@Injectable()\nexport class ErrorsBookingsService_2024_08_13 {\n  private readonly logger = new Logger(\"ErrorsBookingsService_2024_08_13\");\n\n  handleEventTypeToBeBookedNotFound(body: CreateBookingInput): never {\n    if (body.username && body.eventTypeSlug && !body.organizationSlug) {\n      throw new NotFoundException(\n        `Event type with slug ${body.eventTypeSlug} belonging to user ${body.username} not found.`\n      );\n    }\n    if (body.username && body.eventTypeSlug && body.organizationSlug) {\n      throw new NotFoundException(\n        `Event type with slug ${body.eventTypeSlug} belonging to user ${body.username} within organization ${body.organizationSlug} not found.`\n      );\n    }\n    if (body.teamSlug && body.eventTypeSlug && !body.organizationSlug) {\n      throw new NotFoundException(\n        `Event type with slug ${body.eventTypeSlug} belonging to team ${body.teamSlug} not found.`\n      );\n    }\n    if (body.teamSlug && body.eventTypeSlug && body.organizationSlug) {\n      throw new NotFoundException(\n        `Event type with slug ${body.eventTypeSlug} belonging to team ${body.teamSlug} within organization ${body.organizationSlug} not found.`\n      );\n    }\n    throw new NotFoundException(`Event type with id ${body.eventTypeId} not found.`);\n  }\n\n  handleBookingError(error: unknown, bookingTeamEventType: boolean): never {\n    const hostsUnavaile = \"One of the hosts either already has booking at this time or is not available\";","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/bookings/2024-08-13/services/errors.service.ts#L1-L35","documentation":"Thrown by handleEventTypeToBeBookedNotFound when the booking body contains username + eventTypeSlug + organizationSlug and no matching org-scoped user event type was found. NotFoundException (HTTP 404). This is the organization-aware variant of error 321 — the resolver checked within the org namespace and missed.","triggerScenarios":"POST /v2/bookings with { username, eventTypeSlug, organizationSlug } where the user is not a member of that organization, the slug exists only outside the org, the org slug is wrong, or the event type is org-level but belongs to a different user within the org.","commonSituations":"User was removed from the organization but the client still caches the old org context; wrong organizationSlug after a tenant rename; event type was migrated to a team event type and is no longer user-scoped; cross-org confusion in multi-tenant integrations.","solutions":["Confirm membership: GET /v2/organizations/{organizationSlug}/memberships for the user before booking.","Validate the event type exists within the org via the org-scoped event-types endpoint.","Drop organizationSlug if the event type is actually a non-org user event type (lets the 321 branch resolve).","Switch to teamSlug if the event type is now team-owned within the org."],"exampleFix":"// before\nbody: { username: 'alice', eventTypeSlug: 'intro', organizationSlug: 'old-co' }\n\n// after\nbody: { username: 'alice', eventTypeSlug: 'intro', organizationSlug: 'new-co' }","handlingStrategy":"validation","validationCode":"const { username, eventTypeSlug, organizationSlug } = body;\nif (username && eventTypeSlug && organizationSlug) {\n  const memberships = await api.get(`/v2/organizations/${organizationSlug}/memberships`);\n  if (!memberships.data.some(m => m.user.username === username)) throw new Error('user not in org');\n}","typeGuard":"const hasOrgUserSlugCombo = (b: CreateBookingInput): boolean =>\n  !!(b.username && b.eventTypeSlug && b.organizationSlug);","tryCatchPattern":"try { await api.post('/v2/bookings', body); }\ncatch (e) {\n  if (e.response?.status === 404 && /within organization/.test(e.response.data.message)) {\n    /* drop organizationSlug or correct it, then retry */\n  } else throw e;\n}","preventionTips":["Confirm the user is a member of the organization before including organizationSlug.","Refresh organizationSlug after tenant restructures.","Fall back to the non-org branch if the event type is not org-scoped."],"tags":["api","bookings","event-types","organizations","not-found","nestjs"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}