Skip to content

Unable to create events (birthdays) before linux epoch #1343

Description

@abpai94

Checklist

  • I have used the search function for OPEN issues to see if someone else has already submitted the same bug report.
  • I have also used the search function for CLOSED issues to see if the problem is already solved and just waiting to be released.
  • I will describe the problem with as much detail as possible.
  • This is not about the docker image. In that case, contact the authors of the docker image.

Baikal version

0.10.1

PHP version

8.1.32

Steps to reproduce

Baikal version: 0.10.1
Docker deployment: docker.io/ckulka/baikal:0.10.1
Database: Postgres v17.5
Davx5: 4.4.10-ose

Tested with curl command:

echo "BEGIN:VCALENDAR
VERSION:2.0
PRODID:DAVx5/4.4.10-ose ical4j/3.2.19 (org.fossify.calendar)
BEGIN:VEVENT
DTSTAMP:20250516T114141Z
UID:ecdec3bd-efa3-4f5e-96f9-3a64fca0b2dd
SUMMARY:Jane Doe's Birthday
DTSTART;VALUE=DATE:19660209
DTEND;VALUE=DATE:19660210
RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=1
STATUS:CONFIRMED
TRANSP:TRANSPARENT
BEGIN:VALARM
TRIGGER:-PT10M
ACTION:DISPLAY
DESCRIPTION:Jane Doe's Birthday
END:VALARM
END:VEVENT
END:VCALENDAR" > body.txt
curl --digest -u 'johndoe:johndoe' -X PUT https://dav.example.co.uk/dav.php/calendars/johndoe/e175af5b-b871-486a-b23b-2c8027c82f95/ecdec3bd-efa3-4f5e-96f9-3a64fca0b2dd.ics --data "$(cat body.txt)"

Expected behaviour

Create the calendar entries from before the Unix Epoch. Eg. in the example we have birthday in 1966 before the cutoff of 1 January 1970.

Current behaviour

HTTP Response

Response{protocol=h2, code=500, message=, url=https://dav.example.co.uk/dav.php/calendars/johndoe/e175af5b-b871-486a-b23b-2c8027c82f95/ecdec3bd-efa3-4f5e-96f9-3a64fca0b2dd.ics}
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:sabredav-version>4.7.0</s:sabredav-version>
  <s:exception>PDOException</s:exception>
  <s:message>SQLSTATE[23514]: Check violation: 7 ERROR:  new row for relation "calendarobjects" violates check constraint "calendarobjects_firstoccurence_check"
DETAIL:  Failing row contains (1375, BEGIN:VCALENDAR&#13;
VERSION:2.0&#13;
PRODID:DAVx5/4.4.10-ose ical4j/3.2..., ecdec3bd-efa3-4f5e-96f9-3a64fca0b2dd.ics, 5, 1747395699, 71c5bcdcf1be7006cd44e67265cf4995, 463, VEVENT, 0, 2145916800, ecdec3bd-efa3-4f5e-96f9-3a64fca0b2dd).</s:message>
</d:error>

Code

In composer.json of Baikal the following line references the sabre/dav library:

"sabre/dav" : "~4.7.0",

In the sabre/dav library we find the following lines which sets the variable firstOccurence:
https://github.com/sabre-io/dav/blob/7183a67c4c0f890be7d5ceec5331435db1987186/lib/CalDAV/Backend/PDO.php#L668-L669

When setting up Postgres we execute the db.sql file with the following configurations:

firstoccurence INT CHECK (firstoccurence > 0),

The fix is relatively simple, we need to include zero as the constraing value as follows:

    firstoccurence INT CHECK (firstoccurence >= 0),

Deeper issues

Moreover investigating this issue further it seems we need to find ways to fix the issue of negative timestamps being retrieved, I have raised the following issue sabre-io/dav#1588 in the library in question.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions