{"record":{"id":"b0fd11f7fb6ccf63","repo":"calcom/cal.diy","slug":"event-type-with-slug-body-eventtypeslug-belongi","errorCode":null,"errorMessage":"Event type with slug ${body.eventTypeSlug} belonging to user ${body.username} not found.","messagePattern":"Event type with slug (.+?) belonging to user (.+?) 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":12,"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    }","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/bookings/2024-08-13/services/errors.service.ts#L1-L30","documentation":"Thrown by ErrorsBookingsService_2024_08_13.handleEventTypeToBeBookedNotFound when a booking request supplies username + eventTypeSlug but no organizationSlug, and no matching user-owned event type was resolved upstream. It is a NotFoundException (HTTP 404). The same dispatcher routes different combinations (user vs team, with/without org) to different messages — this branch is specifically the non-org user-slug lookup miss.","triggerScenarios":"POST /v2/bookings with body { username, eventTypeSlug } (and no organizationSlug) where the user does not exist, the slug is misspelled/trailing-spaced, the event type belongs to a different user, or the event type is hidden/disabled. The bookings controller calls handleEventTypeToBeBookedNotFound only after the eventType lookup returned null.","commonSituations":"Copy/paste of a slug from a URL with a trailing slash; renamed event type slug after a rebrand; user moved under an organization so the non-org lookup no longer resolves; event type set to 'hidden' or 'unpublished'; dev environment seeded with different usernames than production.","solutions":["Verify the user exists and the slug is current via GET /v2/event-types?username={username} (or the platform event-types endpoint) before booking.","Strip whitespace and trailing slashes from eventTypeSlug and username in the client before sending.","If the user is part of an organization, include organizationSlug so the org-scoped branch resolves instead.","Confirm the event type is published and not hidden from the API."],"exampleFix":"// before\nbody: { username: 'alice ', eventTypeSlug: 'intro-call/' }\n\n// after\nbody: { username: 'alice', eventTypeSlug: 'intro-call' }","handlingStrategy":"validation","validationCode":"const username = body.username?.trim();\nconst eventTypeSlug = body.eventTypeSlug?.trim().replace(/\\/$/, '');\nif (!username || !eventTypeSlug) throw new Error('username and eventTypeSlug required');\nconst et = await api.get(`/v2/event-types?username=${encodeURIComponent(username)}&slug=${encodeURIComponent(eventTypeSlug)}`);\nif (!et.data.length) throw new Error('event type not found — check slug/user');","typeGuard":"const hasUserSlugCombo = (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) { /* re-fetch event type, prompt user for correct slug */ }\n  else throw e;\n}","preventionTips":["Trim and slash-strip slug fields client-side before booking.","Pre-fetch the event type by username+slug to confirm it resolves.","Invalidate cached slugs after event-type renames."],"tags":["api","bookings","event-types","not-found","slug","nestjs"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}