{"record":{"id":"4bb0f68e48c5c007","repo":"calcom/cal.diy","slug":"checkisemailuseraccessible-email-booking-field-m","errorCode":null,"errorMessage":"checkIsEmailUserAccessible - Email booking field must be required and visible","messagePattern":"checkIsEmailUserAccessible - Email booking field must be required and visible","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apps/api/v2/src/platform/event-types/event-types_2024_06_14/services/event-types.service.ts","lineNumber":117,"sourceCode":"    return {\n      ownerId: eventType.userId ?? 0,\n      ...eventType,\n    };\n  }\n\n  async checkCanCreateEventType(userId: number, body: InputEventTransformed_2024_06_14) {\n    const existsWithSlug = await this.eventTypesRepository.getUserEventTypeBySlug(userId, body.slug);\n    if (existsWithSlug) {\n      throw new BadRequestException(\"User already has an event type with this slug.\");\n    }\n    await this.checkUserOwnsSchedule(userId, body.scheduleId);\n  }\n\n  checkHasUserAccessibleEmailBookingField(bookingFields: (SystemField | CustomField)[]) {\n    const emailField = bookingFields.find((field) => field.type === \"email\" && field.name === \"email\");\n    const isEmailFieldRequiredAndVisible = emailField?.required && !emailField?.hidden;\n    if (!isEmailFieldRequiredAndVisible) {\n      throw new BadRequestException(\n        \"checkIsEmailUserAccessible - Email booking field must be required and visible\"\n      );\n    }\n  }\n\n  async getEventTypeByUsernameAndSlug(params: {\n    username: string;\n    eventTypeSlug: string;\n    orgSlug?: string;\n    orgId?: number;\n    authUser?: AuthOptionalUser;\n  }) {\n    const user = await this.usersRepository.findByUsername(params.username, params.orgSlug, params.orgId);\n    if (!user) {\n      return null;\n    }\n\n    const eventType = await this.eventTypesRepository.getUserEventTypeBySlug(user.id, params.eventTypeSlug);","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/event-types/event-types_2024_06_14/services/event-types.service.ts#L99-L135","documentation":"Thrown by EventTypesService_2024_06_14.checkHasUserAccessibleEmailBookingField when the email booking field is not both `required` and not `hidden`. The 2024_06_14 create/update flow enforces that the `email` system field remains user-accessible (required and visible) so booking confirmations and attendee notifications can be delivered. It fires on both create (when bookingFields is provided) and update.","triggerScenarios":"POST or PATCH /v2/event-types (cal-api-version 2024-06-14) with bookingFields where the email field is marked hidden:true, required:false, or is omitted entirely while other bookingFields are supplied; setting the email field to optional; removing the email field from the array.","commonSituations":"Customizing the booking form and accidentally toggling email off; importing an event type config from an older version where email was optional; a frontend builder that lets users hide the email field; partial updates that include bookingFields without the email entry.","solutions":["Ensure the bookingFields array includes an entry with type 'email', name 'email', required true, and hidden false (or omitted/undefined).","When PATCHing only a subset of bookingFields, re-include the email field with required:true and hidden:false.","Validate your payload against the SystemField schema before sending — use the platform-types definition.","If you genuinely need a no-email event type, use a different flow (e.g. managed events) that does not route through this check."],"exampleFix":"// before\nawait api.patch(`/v2/event-types/${id}`, {\n  bookingFields: [{ type: 'email', name: 'email', required: false, hidden: true }]\n}, { headers: { 'cal-api-version': '2024-06-14' } });\n// after\nawait api.patch(`/v2/event-types/${id}`, {\n  bookingFields: [{ type: 'email', name: 'email', required: true, hidden: false }]\n}, { headers: { 'cal-api-version': '2024-06-14' } });","handlingStrategy":"type-guard","validationCode":"// Ensure the email booking field is required and visible before create/update\nfunction ensureEmailFieldAccessible(bookingFields: any[]) {\n  const email = bookingFields.find((f) => f.type === 'email' && f.name === 'email');\n  if (!email || !email.required || email.hidden) {\n    throw new Error('email booking field must be present, required, and not hidden');\n  }\n}","typeGuard":"function hasAccessibleEmailField(fields: unknown): boolean {\n  if (!Array.isArray(fields)) return false;\n  const email = fields.find(\n    (f) => typeof f === 'object' && f !== null && (f as any).type === 'email' && (f as any).name === 'email'\n  );\n  return !!email && (email as any).required === true && !(email as any).hidden;\n}","tryCatchPattern":"try {\n  await api.patch(`/v2/event-types/${id}`, { bookingFields }, { headers: { 'cal-api-version': '2024-06-14' } });\n} catch (e) {\n  if (e.response?.status === 400 && e.response?.data?.message?.includes('Email booking field')) {\n    // re-include the email system field with required:true, hidden:false\n  } else throw e;\n}","preventionTips":["Always include the email system field with required:true and hidden:false in bookingFields payloads.","When PATCHing a subset of bookingFields, merge with the existing set rather than replacing blindly.","Validate the payload with the platform-types SystemField schema in your test suite."],"tags":["nestjs","bad-request","event-types","booking-fields","cal-api-version"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}