这是indexloc提供的服务,不要输入任何密码
Skip to content

Can't Sign Up To Event If There Are No Attendees To The Series #261

@robmoffat

Description

@robmoffat

I see this error in the netlify logs:

Aug 19, 09:15:37 AM: cf27b3d6 INFO   UpdatePromises at time of return:  [
  Promise {
    <rejected> TypeError: event.attendees is not iterable
        at addAttendeeToEvent (/var/task/.cache/functions/signup-submit.js:242512:34)
        at updateEventRequest (/var/task/.cache/functions/signup-submit.js:242535:16)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async /var/task/.cache/functions/signup-submit.js:242571:58
        at async Promise.allSettled (index 0)
  }
]

Looking at the code, we have this:

sync function addAttendeeToEvent(api, calendarId, event, email, addForReal) {

  console.log(`Adding attendee to `, event.id, event.start, event.summary, addForReal)

  const newAttendees = [
    ...event.attendees,
    {
      email: email,
    },
  ]
  const eventId = event.id

  if (addForReal) {
    return await updateAttendees(api, calendarId, eventId, newAttendees)
  }
}

However, if a master event doesn't have attenedees, the event.attendees property is not set. You would have thought it would be an empty array, but it isn't, so we need to add a guard here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions