instructure/canvas-lms · error · CalendarEvent::ReservationError

all slots filled

Error message

all slots filled

What it means

CalendarEvent.reserve_for raises ReservationError when the slot's participants_per_appointment is set and the number of child_events (existing reservations on this slot) already meets that capacity. The slot is full so no additional participant can be added.

Solutions

  1. Show a 'slot is full' message and offer other open slots in the same appointment group.
  2. Re-fetch slot availability immediately before booking to reduce the race window (the lock! calls already serialize server-side).
  3. Increase participants_per_appointment on the appointment group if group bookings genuinely need more seats.

Example fix

// before
slot.reserve_for(user, participant)
// after
if slot.participants_per_appointment && slot.child_events.size >= slot.participants_per_appointment
  render json: { error: 'This time slot is full' }, status: :conflict
else
  slot.reserve_for(user, participant)
end
Defensive patterns

Strategy: try-catch

Validate before calling

if slot.participants_per_appointment && slot.child_events.size >= slot.participants_per_appointment
  raise UserFacingError, 'slot full'
end

Try / catch

begin
  slot.reserve_for(user, participant)
rescue ReservationError => e
  if e.message == 'all slots filled'
    render_slot_full_response
  else
    raise
  end
end

Prevention

When it happens

Trigger: Calling reserve_for on a slot where participants_per_appointment is non-nil and child_events.size >= participants_per_appointment.

Common situations: Two students racing to grab the last spot in a group slot; API scripts retrying a booking that already succeeded; UI showing a stale open slot that another user just filled.

Related errors


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/0462ad6d08da40e7. Report an issue: GitHub.

Appendix: source

Thrown at app/models/calendar_event.rb:609

  def reserve_for(participant, user, options = {})
    raise ReservationError, "not an appointment" unless context_type == "AppointmentGroup"
    raise ReservationError, "ineligible participant" unless context.eligible_participant?(participant)

    transaction do
      lock! # in case two people two participants try to grab the same slot
      participant.lock! # in case two people try to make a reservation for the same participant

      if options[:cancel_existing]
        context.reservations_for(participant).lock.each do |reservation|
          raise ReservationError, "cannot cancel past reservation" if reservation.end_at < Time.now.utc

          reservation.updating_user = user
          reservation.destroy
        end
      end

      raise ReservationError, "participant has met per-participant limit" if context.max_appointments_per_participant && context.reservations_for(participant).size >= context.max_appointments_per_participant
      raise ReservationError, "all slots filled" if participants_per_appointment && child_events.size >= participants_per_appointment
      raise ReservationError, "participant has already reserved this appointment" if child_events_for(participant).present?

      event = child_events.build
      event.updating_user = user
      event.context = participant
      event.workflow_state = :locked
      event.comments = options[:comments]
      event.save!
      if active?
        self.workflow_state = "locked"
        save!
      end
      context.clear_cached_available_slots!
      event
    end
  end

  def child_events_for(participant)

View on GitHub (pinned to 1c9f0bb801)