Skip to content

[Bug] Zero-length periods are accepted #2087

Description

@mayankm00007

Describe the bug

vPeriod accepts a period whose start and end are identical. This creates a zero-length period, although the documented requirement is that the start must come before the end.

To reproduce

from datetime import datetime, timezone

from icalendar.prop import vPeriod

start = datetime(2026, 11, 10, 10, 0, tzinfo=timezone.utc)
period = vPeriod((start, start))

print(period.duration)
print(period.to_ical())

Output:

0:00:00
b'20261110T100000Z/20261110T100000Z'

The same issue occurs when parsing a calendar containing this period:

from icalendar import Calendar

ics = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//example//test//EN
BEGIN:VEVENT
UID:zero-period
DTSTART:20261110T100000Z
RDATE;VALUE=PERIOD:20261110T100000Z/20261110T100000Z
END:VEVENT
END:VCALENDAR
"""

calendar = Calendar.from_ical(ics)
print(calendar.to_ical().decode())

Parsing and serialization both succeed, preserving the zero-length period.

Expected behavior

A period with identical start and end should be rejected, just as a period whose start is after its end is rejected.

Environment

  • Operating system: Arch Linux
  • Python version: Python 3.14.8
  • icalendar version: 7.3.1.dev775 (tested from repository commit f11437e7)

Additional context

The constructor checks whether start > end, but not whether start == end.

  • Tested against the latest GitHub main source at commit f11437e. Installed the local checkout in a clean virtual environment with pip install -e . and confirmed the reproduction succeeds.
  • I included the .ics sample inline above; there is no separate sample file.

Activity

  1. github-actions commented on Nov 10, 2026

    @github-actions
    Contributor

    Thanks for the issue, @mayankm00007! A maintainer will review it shortly.

  2. github-actions commented on Nov 10, 2026

    @github-actions
    Contributor

    Insufficient data

    Not enough activity yet to make a reliable assessment.

    View full analysis →

    This is an automated analysis by AgentScan

  3. mjonu530 commented on Nov 15, 2026

    @mjonu530

    Hi! I'm a new contributor to icalendar, and I was able to reproduce this issue on Windows.

    My environment:

    • OS: Windows
    • Python version: 3.10.11
    • Installation: Local repository using pip install -e .
    • Commit: dc57cfe

    I followed the reproduction example using vPeriod with identical start and end times.

    My output:

    Duration: 0:00:00
    Serialized: b'20261110T100000Z/20261110T100000Z'
    

    The library accepted the zero-length period without raising an exception. This confirms the reported behavior on my Windows setup.

    I also noticed that pull requests are already linked to this issue. Thanks for the work on the fix!

  4. added a commit that references this issue on Nov 23, 2026
    a8aaee0
  5. niccokunzmann commented on Nov 23, 2026

    @niccokunzmann
    Member

    I would argue that zero length periods should be accepted because zero length events are accepted.

    The purpose of PERIOD in RDATE is to shorten the specification of edited occurrences. Should we want to edit a occurrence now, we would create a special case for 0 length that requires a new VEVENT entry with a recurrence id whereas all others can be done with RDATE.

    So, this might strictly adhere to the standard.

    If this was found using AI, I would say it is not worth persuing it. @mayankm00007 How did you find the bug?

    If this was a genuine request from someone who uses icalendar as a production library, then yes, this has a foundation.

    So, I am opening this again with a request to finish the conversation, so I can understand how the use-case came about. I am not debating the fix or the value of the change. That is fine and merged but I would like to know why it is important to restrict the usage for you personally.

  6. stevepiercy commented on Nov 23, 2026

    @stevepiercy
    Member

    @niccokunzmann according to the RFC 5545, Section 3.3.9, under its Description:

    ... The start
    of the period MUST be before the end of the period. Second, a
    period of time can also be defined by a start and a positive
    duration of time.

    The author of this issue referenced "documentation," which is what I assumed they meant. That's why @angatha and I approved and merged #2103.

    The purpose of PERIOD in RDATE is to shorten the specification of edited occurrences. Should we want to edit a occurrence now, we would create a special case for 0 length that requires a new VEVENT entry with a recurrence id whereas all others can be done with RDATE.

    I agree with the first sentence, but not the second as it wouldn't conform with the above specification or that for RDATE.


    Separately, though, this makes it apparent that we have a hole in our issue triage process, which doesn't yet exist. This is not the first time that people have created issues and others jump in to "solve" the issue by creating a PR before it's been confirmed and clarified. Fools rush in.

    I'd suggest that any new issue get automatically labeled with Needs peer review, Needs maintainer review, or even Needs discussion, depending on what you think is appropriate.

    After confirmation, the person confirming the issue would remove that label and add the label Needs help.

    What do you think?


    Finally, I closed the superseded PR #2113.

  7. niccokunzmann commented on Nov 23, 2026

    @niccokunzmann
    Member

    I think, the issue is correct in so far that it is making icalendar more compatible with the standard. Here, however I feel that we are more strict that is required really. I also welcome this change as it allows us to get feedback and give feedback on standard conformance.

    I would still like to hear from @mayankm00007 how the issue was found. Could you help me make sense of it?

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions