Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events starting at 00:00 cause error - calendar.events.insert failed with error: Bad Request #237

Closed
zxmon21 opened this issue Oct 24, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@zxmon21
Copy link

zxmon21 commented Oct 24, 2021

I'm syncing two sports team calendars from ["webcal://cal.laget.se/AlmtunaISTeam09.ics", "AIS09"] and ["webcal://cal.laget.se/aisungdomteam13.ics", "AIS13"]
I get partial syncs only, the script seems to fail at a particular event in each calendar.

When I sync both calendars in the above order, it fails to sync at this 2 whole-days event from the AIS09 calendar:
image

at these lines:

        newEvent = callWithBackoff(function(){
          return Calendar.Events.insert(newEvent, targetCalendarId);
        }, defaultMaxRetries);

with this error message in the debugger:
image

BEGIN:VEVENT
CATEGORIES:Övrig aktivitet
DESCRIPTION:\nÖvrig info\nVi anordnar nyårscupen den 2-3 januari 2022. \nD
et är 16 lag anmälda och matcher kommer ske i alla tre hallarna. För att
vi ska få till en sådan bra cup som möjligt behöver alla föräldrar vara m
ed och hjälpa till under dessa dagar! Anmälan avser därför både spelare o
ch föräldrar. \n\nAnmäl er så fort som som möjligt för att underlätta pla
neringen för cupen. \n\nMer info om cupen (anmälda lag mm) kan ni se på c
uponline: https://www.cuponline.se/start.aspx?cupid=35821
DTEND;TZID=W. Europe Standard Time:20220103T235900
DTSTAMP:20211024T155747Z
DTSTART;TZID=W. Europe Standard Time;VALUE=DATE:20220102
LOCATION:Gränby Ishallar
ORGANIZER;CN=Almtuna IS Team 09:
PRIORITY:5
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Nyårscupen
TRANSP:OPAQUE
UID:20220102T000000-20977297@laget.se
END:VEVENT

If I reverse the order of the calenders, sync fails at this event:
image

with the same error:
GoogleJsonResponseException: API call to calendar.events.insert failed with error: Bad Request
(anonymous) @ Helpers.gs:233
callWithBackoff @ Helpers.gs:882
processEvent @ Helpers.gs:232
(anonymous) @ Code.gs:206
startSync @ Code.gs:205

BEGIN:VEVENT
CATEGORIES:Match
DESCRIPTION:\n\nLäs mer om matchen\nhttps://www.laget.se/aisungdomteam13/D
ivision/Game/473413/8638572
DTEND;TZID=W. Europe Standard Time:20211204T020000
DTSTAMP:20211024T193804Z
DTSTART;TZID=W. Europe Standard Time;VALUE=DATE:20211204
LOCATION:Contigahallen
ORGANIZER;CN=Almtuna IS Team13:
PRIORITY:5
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Match Almtuna IS1 - Norrtälje IK2
TRANSP:OPAQUE
UID:20211204T000000-20928818@laget.se
END:VEVENT

I notice that both events have one thing in common: They start at 00:00 of the day, and their DTSTART string contains DATE:YYYYMMDD, but no time information.


I'm a complete newbee at JavaScript/GoogleScript. But I tried to attach a time to the newEvent startDate as follows:

      if (addEventsToCalendar){
        if (newEvent.start.date.length = 10){
          Logger.log(newEvent.start.date.length)
          Logger.log(newEvent);
          newEvent.start.date = newEvent.start.date + "T00:00:01"
          Logger.log(newEvent);
          Logger.log(newEvent.start.date.length)
        }

The error message is still there :(

@zxmon21 zxmon21 added the bug Something isn't working label Oct 24, 2021
@jonas0b1011001
Copy link
Collaborator

There are two issues with the events' dtStart/dtEnde values.

  1. You are not supposed to mix VALUE=DATE and VALUE=DATE-TIME

These events have a DATE value type for the "DTSTART" property instead of the default value type of DATE-TIME. If such a "VEVENT" has a "DTEND" property, it MUST be specified as a DATE value also.

  1. Values defined as Date are not supposed to have a timezone

This is the label by which a time zone calendar component is referenced by any iCalendar properties whose value type is either DATE-TIME or TIME and not intended to specify a UTC or a "floating" time.

Properly formatted, the first event should look like this:

BEGIN:VEVENT
CATEGORIES:Övrig aktivitet
DESCRIPTION:\nÖvrig info\nVi anordnar nyårscupen den 2-3 januari 2022. \nD
et är 16 lag anmälda och matcher kommer ske i alla tre hallarna. För att
vi ska få till en sådan bra cup som möjligt behöver alla föräldrar vara m
ed och hjälpa till under dessa dagar! Anmälan avser därför både spelare o
ch föräldrar. \n\nAnmäl er så fort som som möjligt för att underlätta pla
neringen för cupen. \n\nMer info om cupen (anmälda lag mm) kan ni se på c
uponline: https://www.cuponline.se/start.aspx?cupid=35821
DTEND;VALUE=DATE:20220104
DTSTAMP:20211024T155747Z
DTSTART;VALUE=DATE:20220102
LOCATION:Gränby Ishallar
ORGANIZER;CN=Almtuna IS Team 09:
PRIORITY:5
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Nyårscupen
TRANSP:OPAQUE
UID:20220102T000000-20977297@laget.se
END:VEVENT

@zxmon21
Copy link
Author

zxmon21 commented Oct 28, 2021

Thanks for the good explanation. I guess I'll contact the publisher of the calendar to correct their format for events starting at 00:00.

I also saw that the event that causes the crash has a SEMICOLON after the time zone information, rather than a regular colon ":". Looks fishy...

I consider this closed

@zxmon21 zxmon21 closed this as completed Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants