Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

One object that does not parse makes a post-filtered search() raise for the whole calendar

Đang mở
#815 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
65/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Start with _filter_search_results() in caldav/search.py around line 80 and trace how ValueError is handled during post-filtering. Reproduce with the supplied malformed VTODO and valid object, then check existing tests for client-side search filtering. Done when a malformed object no longer makes the whole search raise and the caller can learn which object failed, as the issue requests.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Disclaimer: AI-generated text below the line, generated by Claude Opus 5.5.
Found while working on https://github.com/pycalendar/calendaring/pull/13


When Calendar.search() filters the results on the client side, one stored object that icalendar cannot parse makes the whole search raise a plain ValueError. None of the other objects come back.

_filter_search_results() (caldav/search.py, around line 80) calls searcher.check_component(o, ...), and on ValueError falls back to o.icalendar_instance.subcomponents. That parses the same data again, so it raises again:

try:
    filtered = searcher.check_component(o, expand_only=not post_filter)
except ValueError:
    filtered = [
        x for x in o.icalendar_instance.subcomponents if not isinstance(x, Timezone)
    ]

The post-filter is on by default in many cases (search.py, "Setting default value for post_filter"). Among them: a time range that caldav widened itself, todo=True without include_completed, and any server without search.text.case-sensitive (per the hints: Radicale, SOGo, CCS, Stalwart), where it is on for every search. get_object_by_uid() always post-filters. So on those servers, one malformed object written by some other client makes every search in that calendar fail.

Reproduction against caldav 3.6.0, without a server:

from caldav import DAVClient
from caldav.calendarobjectresource import Todo
from caldav.search import CalDAVSearcher, _filter_search_results

BAD = ("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//some client//EN\r\nBEGIN:VTODO\r\nUID:from-phone\r\n"
       "DTSTAMP:20261001T000000Z\r\nSUMMARY:buy milk\r\nDUE:2026-10-20\r\nEND:VTODO\r\nEND:VCALENDAR\r\n")
GOOD = BAD.replace("UID:from-phone", "UID:good").replace("DUE:2026-10-20", "DUE;VALUE=DATE:20261020")
client = DAVClient(url="https://caldav.example.com/")
objects = [Todo(client=client, url=f"https://caldav.example.com/cal/{n}.ics", data=d)
           for n, d in (("good", GOOD), ("bad", BAD))]
searcher = CalDAVSearcher(todo=True)
print(len(_filter_search_results(objects, searcher, post_filter=False)))  # 2
_filter_search_results(objects, searcher, post_filter=True)
# ValueError: Expected datetime, date, or time. Got: '2026-10-20'

(DUE:2026-10-20 is not a valid DATE value; such data is out there.)

Possible fix: skip an object that does not parse, with a log warning, or collect such objects and hand them back to the caller, instead of letting the exception escape. Skipping silently would hide data, so some way for the caller to learn about the skipped objects would be better.

Ngôn ngữ chính
Python
Star
412
Fork
113
Merge trung bình
9 giờ 52 phút
Pull request đã merge (30 ngày)
64

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của python-caldav/caldav

Tất cả issue của python-caldav/caldav

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.