Search code examples
javaicalendarparseexceptionical4j

Error parsing Google icals using ical4j library


The system I am working on has been using the ical4j library to sync our user's google calendars with our built in calendar for a while now and was working fine until a couple weeks ago when their calendars stopped synching. A quick look into the logs reveals the following stack trace:

=75213399 2016-01-15 14:37:33,574 [task-scheduler-5] INFO  org.springframework.integration.mail.ImapMailReceiver  - attempting to receive mail from folder [INBOX]
=75214067 2016-01-15 14:37:34,242 [calendar-9] INFO  com.starfish.batch.integration.GoogleCalendarParser  - Using temp dir /var/log/starfish/starfish-batch-stage
=75214070 2016-01-15 14:37:34,245 [calendar-9] ERROR com.starfish.batch.integration.GoogleCalendarParser  - Exception getting user google cal for 4829on try number 2 trying again.
net.fortuna.ical4j.data.ParserException: Error at line 841:Invalid parameter name: FILENAME
    at net.fortuna.ical4j.data.CalendarParserImpl.parse(CalendarParserImpl.java:148)
    at net.fortuna.ical4j.data.CalendarBuilder.build(CalendarBuilder.java:211)
    at net.fortuna.ical4j.data.CalendarBuilder.build(CalendarBuilder.java:192)
    at.....

I used an online ical validation tool (http://severinghaus.org/projects/icv/) based on the same library to verify the error.

The part of the ical that produces the parse exception is (client info omitted):

ATTACH;FILENAME=Reading Day Holiday Lunch 2015.docx:https://drive.google.co
 m/a/ZZZZ.edu/file/d/ZZZZZZZZZZZZZZZZZZZZZZZZ/view?usp=drive_web

Our system is using ical4j version 1.0-rc3-SNAPSHOT.

I researched if google had made changes to the way they generate their icals but was not able to find anything. I maybe searching in the wrong places. Has anyone encountered this issue and if so, what was done to resolve it?

Is anyone aware of any changes that google might have made that would cause this exception?

Would the user's attachment location have anything to do with it?


Solution

  • By default, ical4j strictly adheres to the default set of registered property defined in RFC5545. This means that any property or parameter not defined in RFC5545 should be prefixed with X-.

    The particular parameter (FILENAME) that you are struggling with was added as part of https://datatracker.ietf.org/doc/html/draft-daboo-caldav-attachments-03#section-4.2 .

    To overcome this, you want to set

    ical4j.parsing.relaxed=true

    either in your ical4j.properties (which should itself be at the root of your ical4j.jar jar file) or as a system property.

    Now, I'm not 100% sure that the version of ical4j that you are using does include the right fix for this, so you may also want to upgrade to a later version from https://github.com/ical4j/ical4j