From dbd7b790792a54cb0256fe638a9bb7caf7f285f8 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Wed, 4 Nov 2026 14:27:46 +0100 Subject: [PATCH 1/8] docs: grouping nodes have no verdict of their own The fix proposed in TODO_COMPATIBILITY_HINTS item 8 removes the skip of children with a default. Comparing every feature over all server profiles shows it marks working features unsupported, for instance sync-token.delete on Xandikos and Stalwart. Keep the derivation, say in the docstring of _derive_from_subfeatures that such a node answers from the type default, and close item 8 as won't fix with the results. Prompt: [pick from the task list: "Let grouping nodes without a default derive from children that have one"] Prompts (comments made inline in the document while reviewing it): > (on "no default" meaning both a grouping node and a real capability without a default) A real capability that has no default could have an explicit "unknown". > I think it was decided earlier that explicit defaults aren't important for leaf nodes, but for the parents an explicit default signifies that it's an independent feature that should be probed, without explcit (sic) default it's just a grouping node > but [leaving the behaviour as-is and documenting it] is probably good enough Assisted-By: Claude Opus 5.5 Reviewed-by: Tobias Brox --- caldav/compatibility_hints.py | 13 +++++- docs/design/TODO_COMPATIBILITY_HINTS.md | 57 ++++++++++++++++++++++--- 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/caldav/compatibility_hints.py b/caldav/compatibility_hints.py index fcb9b4bd..6c939a9a 100644 --- a/caldav/compatibility_hints.py +++ b/caldav/compatibility_hints.py @@ -1432,7 +1432,8 @@ def _derive_from_subfeatures(self, feature, feature_info, return_type, accept_fr Derive parent feature status from explicitly set subfeatures. Logic: - - Only consider subfeatures WITHOUT explicit defaults (those are independent features) + - Only consider subfeatures WITHOUT explicit defaults (subfeatures with a default are + independent features and are skipped) - If ANY relevant subfeature has a positive status (full/quirk) → derive as that status (any support means the parent has some support) - If ALL relevant subfeatures are set AND all have the same negative status → use that status @@ -1442,6 +1443,16 @@ def _derive_from_subfeatures(self, feature, feature_info, return_type, accept_fr Returns None if no relevant subfeatures are explicitly set or if derivation is inconclusive due to partial information. + + An explicit default on a node marks it as an independent feature, one + that is probed on its own. A parent node without one is treated as a + grouping node. A grouping node whose subfeatures all have explicit + defaults (``auth``, ``http``) therefore has no verdict of its own: + nothing is derived, and unless the node or an ancestor is set in the + server's features, is_supported() answers from the type default + whatever the subfeatures say. Ask the subfeatures instead. A real + capability that lacks a default and needs its own answer should get + an explicit ``unknown`` default. """ if 'subfeatures' not in feature_info or not feature_info['subfeatures']: return None diff --git a/docs/design/TODO_COMPATIBILITY_HINTS.md b/docs/design/TODO_COMPATIBILITY_HINTS.md index 1fdcd8f5..f93bc224 100644 --- a/docs/design/TODO_COMPATIBILITY_HINTS.md +++ b/docs/design/TODO_COMPATIBILITY_HINTS.md @@ -110,7 +110,7 @@ Possibly into three files (or four, with the original compatibility_hints.py bei There are three quite different things in the file now, the database of the feature names/flags, the database of server compatibility, and the match logic. -## 8. A grouping node cannot derive from a child that has a default +## 8. A grouping node cannot derive from a child that has a default (won't fix, documented) **Location**: `FeatureSet._derive_from_subfeatures`, the `continue` on `'default' in subfeature_info` @@ -124,15 +124,58 @@ marks it as independently probed. So a grouping node whose children are all real, probed features derives nothing, falls through to `_default()`, and answers `full` whatever its children say. -Six nodes have that shape today: `http`, `non-existing-raises-not-found`, +Nine nodes have that shape today: `http`, `non-existing-raises-not-found`, `save-load.event.recurrences.exception`, `save-load.icalendar`, -`url.encode-at` and `auth`. `is_supported("non-existing-raises-not-found")` +`url.encode-at`, `auth`, `supported-components`, `sync-token.delete` and +`scheduling.calendar-user-address-set`. `is_supported("non-existing-raises-not-found")` returns `full` on a server where both children are `unsupported`. -**Fix**: skip a child with its own default only when the *parent* has one too. -A grouping node should derive from all its children, real ones included. The -existing OR-semantics note on `principal-search` suggests the derivation rules -want a second look at the same time. +**Proposed fix, and why it does not work as stated**: skip a child with its own +default only when the *parent* has one too. Both callers of +`_derive_from_subfeatures` already require a parent without a default, so this +amounts to removing the skip. Answers for every feature over all 25 server +profiles, before and after: + +* `scheduling.calendar-user-address-set` goes to `unsupported` on Xandikos, while + the description of `.populated` says an empty property still means the parent + is supported. +* `sync-token.delete` goes to `unsupported` on Xandikos and Stalwart, because + `.created-and-deleted` is. Those profiles state no fault on the parent, and + the integration tests guarded by this feature would be skipped. +* `http` goes to `unsupported` on DAViCal and Synology and to `fragile` on + Baikal, `auth` to `unsupported` on Yahoo: all + say only that the one child is missing. +* `supported-components` goes to `unknown` on Purelymail and Robur, against the + comment on the node. A test pins the node at `full` for a single child set + (`test_an_absent_property_leaves_the_grouping_node_alone`). +* `save`, `save.duplicate-uid` and (on Xandikos and Stalwart) + `save.duplicate-uid.cross-calendar` go to `quirk`, and `search.time-range.open` to + `unknown`: nodes with default-less children too, which pick up the new verdict. + +Restricting the change to parents whose children *all* have a default removes +the last group only. The existing tests pass under either variant, so they do +not protect against any of this. + +The missing default on these nodes means two things: "only groups" and "real +capability that happens to have no default". `delete`, +`sync-token.delete`, `scheduling.calendar-user-address-set` and +`save-load.event.recurrences.exception` are the second kind. The last one is +read by `search.py`, which switches to server-side expansion when it is false; no +profile changes today, but `.cancelled` and `.reschedule` both negative, or mixed, +would trigger that switch for unrelated reasons. + +Of the pure grouping nodes listed above only `non-existing-raises-not-found` gains a meaningful +answer (`unknown` on Robur), and nothing in the library reads it. + +**Decided 2026-11-11: won't fix, documented.** The behaviour stays, and the +docstring of `_derive_from_subfeatures` now says that such a node has no +verdict of its own. The alternative, marking the nodes meant to aggregate in +`FEATURES` and deriving only for those, would add a schema key for a node +without a reader. The convention stands: an explicit default on a node marks +an independent feature that is probed; without one, the node only groups. +Should a real capability without a default ever need its own answer, the way +out is to give it an explicit `unknown` default. The OR-semantics note on +`principal-search` is untouched by this. ## Ordering / dependencies From adc32723b2f3fa381da1fc7f79013827c38c3197 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Wed, 18 Nov 2026 06:54:05 +0100 Subject: [PATCH 2/8] test: a bare STALWART_USERNAME gets the domain setup_stalwart.sh read STALWART_USERNAME as a local part and created @example.org, while StalwartTestServer used it as the whole login, so STALWART_USERNAME=foo set up one account and logged in as another. Both now take either a local part or a full address. Prompts: > fix [the review finding: STALWART_USERNAME means a local part to the > setup script and a full login to the client] Assisted-By: Claude Opus 5.5 Reviewed-by: Tobias Brox --- caldav/testing/docker.py | 10 ++++++---- .../stalwart/setup_stalwart.sh | 1 + tests/test_testing.py | 20 +++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/caldav/testing/docker.py b/caldav/testing/docker.py index 23b87e72..76fd60d8 100644 --- a/caldav/testing/docker.py +++ b/caldav/testing/docker.py @@ -500,10 +500,12 @@ def __init__(self, config: dict[str, Any] | None = None) -> None: port = int(config.get("port") or os.environ.get("STALWART_PORT", "8809")) config.setdefault("host", host) config.setdefault("port", port) - # v0.16+: username is a full email address; default matches setup_stalwart.sh - config.setdefault( - "username", os.environ.get("STALWART_USERNAME", f"testuser@{self._domain}") - ) + # v0.16+: the login is a full email address. STALWART_USERNAME may + # be a bare local part, as setup_stalwart.sh reads it. + username = os.environ.get("STALWART_USERNAME", "testuser") + if "@" not in username: + username = f"{username}@{self._domain}" + config.setdefault("username", username) config.setdefault("password", os.environ.get("STALWART_PASSWORD", "testcaldav")) if "features" not in config: config["features"] = compatibility_hints.stalwart_1_1.copy() diff --git a/tests/docker-test-servers/stalwart/setup_stalwart.sh b/tests/docker-test-servers/stalwart/setup_stalwart.sh index 0fcfe2b9..ed9ce32b 100755 --- a/tests/docker-test-servers/stalwart/setup_stalwart.sh +++ b/tests/docker-test-servers/stalwart/setup_stalwart.sh @@ -23,6 +23,7 @@ ADMIN_USER="admin" ADMIN_PASSWORD="adminpass" DOMAIN="example.org" TEST_USER="${STALWART_USERNAME:-testuser}" +TEST_USER="${TEST_USER%@*}" # the local part, if a full address is given TEST_PASSWORD="${STALWART_PASSWORD:-testcaldav}" JMAP_URL="http://localhost:${HOST_PORT}/jmap" diff --git a/tests/test_testing.py b/tests/test_testing.py index 16163ebd..30d474b5 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -40,3 +40,23 @@ def test_xandikos_stop_closes_event_loop() -> None: loop = server.xapp_loop server.stop() assert loop.is_closed() + + +@pytest.mark.parametrize( + ("env", "login"), + [ + ("foo", "foo@example.org"), + ("foo@example.org", "foo@example.org"), + ], +) +def test_stalwart_username_is_completed_with_the_domain( + monkeypatch: pytest.MonkeyPatch, env: str, login: str +) -> None: + """setup_stalwart.sh reads STALWART_USERNAME as a local part; the + client must log in as the account the script created.""" + from caldav.testing.docker import StalwartTestServer + + monkeypatch.setenv("STALWART_USERNAME", env) + server = StalwartTestServer() + assert server.username == login + assert server.url.endswith("/dav/cal/foo%40example.org/") From 0384500dbbd0ace4b84175cc9dde62b70e22b386 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Sat, 24 Oct 2026 16:12:17 +0200 Subject: [PATCH 3/8] docs: README for the Stalwart test container Stalwart was the one docker test server without a README. It lists the credentials and environment variables, and explains the lowered WebDav.maxResults (50, set by STALWART_MAX_RESULTS): a test putting more objects than that in one calendar gets a 507 from Stalwart. Prompt: [Fix review findings] Assisted-By: Claude Opus 5.5 (1M context) Reviewed-by: Tobias Brox --- tests/docker-test-servers/stalwart/README.md | 39 ++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/docker-test-servers/stalwart/README.md diff --git a/tests/docker-test-servers/stalwart/README.md b/tests/docker-test-servers/stalwart/README.md new file mode 100644 index 00000000..4de20741 --- /dev/null +++ b/tests/docker-test-servers/stalwart/README.md @@ -0,0 +1,39 @@ +# Stalwart Test Server + +[Stalwart](https://stalw.art/) is a mail and collaboration server with CalDAV +and CardDAV support. This configuration runs the `stalwartlabs/stalwart` +image and sets it up over JMAP. + +## Quick Start + +```bash +cd tests/docker-test-servers/stalwart +./start.sh +``` + +## Configuration + +- **URL**: http://localhost:8809/dav/cal/testuser%40example.org/ +- **Admin**: admin / adminpass (web UI: http://localhost:8809/admin/) +- **Test user**: testuser@example.org / testcaldav +- **Scheduling users**: user1, user2, user3 @example.org / caldavtest1..3 + +## Environment Variables + +| Variable | Default | Description | +|----------|---------|-------------| +| `STALWART_HOST` | localhost | Host the client and setup script talk to | +| `STALWART_PORT` | 8809 | Port the client and setup script talk to (`docker-compose.yml` maps 8809 itself) | +| `STALWART_USERNAME` | testuser | Test user, a local part or a full `@example.org` address | +| `STALWART_PASSWORD` | testcaldav | Test password | +| `STALWART_MAX_RESULTS` | 50 | `WebDav.maxResults` | + +## Result limit + +Stalwart caps PROPFIND, sync-collection, calendar-query and +calendar-multiget answers at +`WebDav.maxResults` members, with a 507 for the collection. The default +is 2000; this container lowers it to 50, so caldav-server-tester can see +the limit with few objects (`CALDAV_SERVER_TESTER_LIMIT_OBJECTS`). A test +putting more than 50 objects in one calendar will hit it: raise +`STALWART_MAX_RESULTS` for that. From 324e4b5f7c5a138d0b4d568679a48dd6430ec593 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Mon, 16 Nov 2026 08:35:37 +0100 Subject: [PATCH 4/8] docs: CCS in the initial-sync description The description listed Stalwart as the server that also lists the collection itself on an initial sync; the CCS profile says the same. Prompt: [Fix review findings] Assisted-By: Claude Opus 5.5 Reviewed-by: Tobias Brox --- caldav/compatibility_hints.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caldav/compatibility_hints.py b/caldav/compatibility_hints.py index 6c939a9a..e0a47a5c 100644 --- a/caldav/compatibility_hints.py +++ b/caldav/compatibility_hints.py @@ -893,7 +893,7 @@ class FeatureSet: "links": ["https://datatracker.ietf.org/doc/html/rfc6578#section-3.5.1"], }, "sync-token.initial-sync": { - "description": "A sync report from an empty token lists exactly the current members of the collection: RFC 6578 section 3.4 says it MUST NOT return removed members. 'quirk' when it lists more, which a client can filter away (keep only hrefs below the collection, answered 200): Radicale lists deleted members with a 404, Stalwart also lists the collection itself. The behaviour says which. The limit on an initial sync is sync-token.limit.initial-sync, which inherits from sync-token.limit rather than from this.", + "description": "A sync report from an empty token lists exactly the current members of the collection: RFC 6578 section 3.4 says it MUST NOT return removed members. 'quirk' when it lists more, which a client can filter away (keep only hrefs below the collection, answered 200): Radicale lists deleted members with a 404, Stalwart and CCS also list the collection itself. The behaviour says which. The limit on an initial sync is sync-token.limit.initial-sync, which inherits from sync-token.limit rather than from this.", "default": {"support": "full"}, "links": ["https://datatracker.ietf.org/doc/html/rfc6578#section-3.4"], }, From c39caafd590135a4d3313d9c99bc4811350b6d3e Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Fri, 30 Oct 2026 21:30:55 +0100 Subject: [PATCH 5/8] docs(roadmap): tick items done since the roadmap Negated searches (2.1) landed in v3.5.0 apart from server detection and functional tests; conflicts raise UidConflictError naming the holder (4.1); non-GET redirects, PROPFIND included, are followed on the same origin with a loop limit (4.3). Closed issues 71, 94, 612 and 680 are ticked. https://github.com/python-caldav/caldav/pull/750 https://github.com/python-caldav/caldav/pull/833 https://github.com/python-caldav/caldav/pull/837 Prompt: Please check all the checkboxes that should be checked [in the NLnet-funded roadmaps, while drafting payment requests] Assisted-By: Claude Opus 5.5 (Claude Code) Reviewed-by: Tobias Brox --- docs/design/FEATURE_COMPLETE_ROADMAP.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/design/FEATURE_COMPLETE_ROADMAP.md b/docs/design/FEATURE_COMPLETE_ROADMAP.md index a7bae4bf..1e54a2e2 100644 --- a/docs/design/FEATURE_COMPLETE_ROADMAP.md +++ b/docs/design/FEATURE_COMPLETE_ROADMAP.md @@ -176,11 +176,11 @@ The v3.2 roadmap covers basic scheduling improvements. Additional work for full - **Related issue:** [#568](https://github.com/python-caldav/caldav/issues/568) **Tasks:** -- [x] Add `negate="yes"` attribute support in text-match filters — the `cdav.TextMatch(..., negate=True)` element exists and is used internally (`search.py` `vNotCompleted`/`vNotCancelled`); what is missing is exposing it through the public search API -- [ ] Update `CalDAVSearcher` to support `!=` operator +- [x] Add `negate="yes"` attribute support in text-match filters — the `cdav.TextMatch(..., negate=True)` element exists and is used internally (`search.py` `vNotCompleted`/`vNotCancelled`) +- [x] Update `CalDAVSearcher` to support `!=` operator — **done in v3.5.0** (https://github.com/python-caldav/caldav/pull/750): `add_property_filter()` takes `!=` (alias `<>`), `!contains` and `def` - [ ] Add server compatibility detection -- [ ] Implement client-side fallback filtering for non-supporting servers -- [ ] Unit and functional tests +- [x] Implement client-side fallback filtering for non-supporting servers — **done in v3.5.0**: `search()` filters the negated operators client-side, as no server has been probed for `negate-condition` yet +- [ ] Unit and functional tests — unit tests are in `tests/test_search.py`; no functional test yet --- @@ -312,7 +312,7 @@ change notifications. Requested by the proposal authors themselves. - [x] Proper `If-Match` / `If-None-Match` header usage — `If-Match` is sent when an ETag is cached (and `If-Schedule-Tag-Match` takes precedence when a Schedule-Tag is) on save, and on delete with `delete(if_match=True)` (https://github.com/python-caldav/caldav/issues/740); `save(no_overwrite=True)` sends `If-None-Match: *` (not on servers where `save.if-none-match` is unsupported), and leaves out its UID search where the server refuses a duplicate UID (`save.no-uid-conflict`, and its `.if-none-match` child, full, quirk or ungraceful) - with a GET of the URL in place of the header where `save.if-none-match` is unsupported. `save(no_create=True)` sends `If-Match: *` instead of searching, where `save-load.mutable.if-match-wildcard` is full and no ETag or Schedule-Tag is cached - [ ] Handle UID vs path name mismatches - [ ] Race condition mitigation -- [ ] Clear error messages for conflicts +- [x] Clear error messages for conflicts — `UidConflictError` and its subclasses (https://github.com/python-caldav/caldav/issues/756), naming the object holding the UID in `href` where the server tells (https://github.com/python-caldav/caldav/pull/833), and the `DAV:error` precondition kept on every error (https://github.com/python-caldav/caldav/pull/759) --- @@ -351,9 +351,9 @@ change notifications. Requested by the proposal authors themselves. - **Related issue:** [#552](https://github.com/python-caldav/caldav/issues/552) **Tasks:** -- [ ] Follow 3xx redirects on PROPFIND — still open, and there is a comment in `davclient.py` marking the spot -- [ ] Update internal URLs after redirect -- [ ] Prevent redirect loops +- [x] Follow 3xx redirects on PROPFIND — every method but GET and HEAD is repeated at the `Location` of a 301/302/307/308 on the same scheme, host and port, with its body (`BaseDAVClient._redirect_target()`, https://github.com/python-caldav/caldav/pull/837) +- [ ] Update internal URLs after redirect — done for PUT and MKCOL/MKCALENDAR (`redirected_to`), not for PROPFIND +- [x] Prevent redirect loops — `MAX_REDIRECTS = 5` --- @@ -593,7 +593,7 @@ features. - [ ] Reduce the remaining sync/async code duplication ([#665](https://github.com/python-caldav/caldav/issues/665)) - [ ] Parse all server iCalendar through `vcal.parse_ical()` consistently ([#698](https://github.com/python-caldav/caldav/issues/698)) - [ ] Shrink the ruff ignore list ([#634](https://github.com/python-caldav/caldav/issues/634)) -- [ ] `object.id` should always work ([#94](https://github.com/python-caldav/caldav/issues/94)) +- [x] `object.id` should always work ([#94](https://github.com/python-caldav/caldav/issues/94)) — closed as a duplicate of the closed #96; what is left is #515 (8.1) - [ ] Keep the raw string and the icalendar object side by side instead of either-or, and skip saving unmodified objects. Needs change tracking in `icalendar`, requested in [icalendar#1922](https://github.com/PyCalendar/icalendar/issues/1922) @@ -620,12 +620,12 @@ features. These open issues are bug reports, support questions or automated noise rather than roadmap items, and are deliberately left out: -- [ ] [#71](https://github.com/python-caldav/caldav/issues/71) (`add_event` can update as well), +- [x] [#71](https://github.com/python-caldav/caldav/issues/71) (`add_event` can update as well), - [ ] [#545](https://github.com/python-caldav/caldav/issues/545) (searches return full-day events of adjacent days), -- [ ] [#612](https://github.com/python-caldav/caldav/issues/612) (support question), +- [x] [#612](https://github.com/python-caldav/caldav/issues/612) (support question), - [ ] [#624](https://github.com/python-caldav/caldav/issues/624) (GMX calendar creation), - [ ] server-specific breakage reports ... - - [ ] [#680](https://github.com/python-caldav/caldav/issues/680) + - [x] [#680](https://github.com/python-caldav/caldav/issues/680) - [x] [#681](https://github.com/python-caldav/caldav/issues/681) - [ ] [#684](https://github.com/python-caldav/caldav/issues/684) - [x] [#685](https://github.com/python-caldav/caldav/issues/685) (automated link-checker report). From 6321d240ad4d0c178112e188afbc22026a7c1ef1 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Wed, 18 Nov 2026 08:14:04 +0100 Subject: [PATCH 6/8] build: skip devguide.calconnect.org in link checks Its TLS certificate expired on 2026-11-14 and was not renewed, and the link check refuses every push touching the roadmap that links it. The link itself is fine; the exception goes once the site serves a valid certificate again. Prompt: what is the likelihood of devguide.calconnect.org being fixed soon? Perhaps add an exception, with a calendar-todo to follow up? Assisted-By: Claude Opus 5.5 Reviewed-by: Tobias Brox --- .lycheeignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.lycheeignore b/.lycheeignore index d4782db8..0232f382 100644 --- a/.lycheeignore +++ b/.lycheeignore @@ -44,6 +44,10 @@ https?://davical\.bekkenstenveien53c\.oslo\.no/.* # browser; lychee just isn't one. https://stackoverflow\.com/.* +# TLS certificate expired 2026-11-14 and was not renewed. Drop this +# once the site serves a valid one again. +https://devguide\.calconnect\.org/.* + # Dead or broken links we can't fix http://fsf\.org/.* http://oxpedia\.org/.* From 3775f978fed0d3019e04e9b84732809fb879f84c Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Fri, 20 Nov 2026 16:29:17 +0100 Subject: [PATCH 7/8] perf: keep the listing's properties on calendars get_calendars() asks for supported-calendar-component-set, getctag and calendar-color in its depth-1 PROPFIND, but kept only the display name. A client wanting a calendar's component set then sent one PROPFIND per calendar: calendaring took 268 s for 469 calendars on a Synology server, against 6 s for the listing alone. Each Calendar now gets every property the listing answered in its props, and get_supported_components(use_cached=True) answers from there; a 404 property stays absent, so it is still fetched when asked for. Prompt: [pick from the task list: "calendaring: list collections with one PROPFIND, not one per calendar"] Assisted-By: Claude Opus 5.5 Reviewed-by: Tobias Brox --- caldav/base_client.py | 2 +- caldav/collection.py | 17 +++++++-- changes/+listing-props.changed.md | 1 + tests/test_caldav_unit.py | 62 +++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 changes/+listing-props.changed.md diff --git a/caldav/base_client.py b/caldav/base_client.py index fc2a389c..3a81d775 100644 --- a/caldav/base_client.py +++ b/caldav/base_client.py @@ -645,7 +645,7 @@ def _build_calendars_from_propfind(self, list_response: Any, guess: bool = False _raise_unless_propfind_ok(list_response) calendar_infos = extract_calendars(list_response.results, features=self.features) return [ - Calendar(client=self, url=info.url, name=info.name, id=info.cal_id) + Calendar(client=self, url=info.url, id=info.cal_id, props=info.props) for info in calendar_infos ] diff --git a/caldav/collection.py b/caldav/collection.py index 6a7482ca..b2c0ffbb 100644 --- a/caldav/collection.py +++ b/caldav/collection.py @@ -16,7 +16,7 @@ import uuid import warnings from collections.abc import Generator -from dataclasses import dataclass +from dataclasses import dataclass, field from datetime import date as _date from datetime import datetime, timezone from time import sleep @@ -96,6 +96,8 @@ class CalendarInfo: cal_id: str | None name: str | None resource_types: list[str] + #: Every property the listing answered, as ``get_properties()`` parses them + props: dict[str, Any] = field(default_factory=dict) def _extract_calendar_id_from_url(url: str) -> str | None: @@ -170,6 +172,7 @@ def _extract_calendars_from_propfind_results( cal_id=cal_id, name=name, resource_types=result.properties.get("{DAV:}resourcetype", []), + props=dict(result.properties), ) ) return calendars @@ -238,7 +241,9 @@ def _calendars_from_response(self, response) -> list["Calendar"]: response.results, features=features ) return [ - Calendar(client=self.client, url=info.url, name=info.name, id=info.cal_id, parent=self) + Calendar( + client=self.client, url=info.url, id=info.cal_id, parent=self, props=info.props + ) for info in calendar_infos ] @@ -1262,12 +1267,15 @@ def _supported_components_from_response(self, response: Any, with_fallback: bool return rfc_default def get_supported_components( - self, with_fallback=True + self, with_fallback=True, use_cached=False ) -> "list[Any] | Coroutine[Any, Any, list[Any]]": """ returns a list of component types supported by the calendar, in string format (typically ['VJOURNAL', 'VTODO', 'VEVENT']) + With ``use_cached``, a set already in ``props`` - from the + get_calendars() listing - is returned without asking the server. + RFC 4791 section 5.2.3: supported-calendar-component-set is optional. When absent, the server MUST accept all component types, so we return the RFC default list (trimmed by known server limitations from @@ -1276,6 +1284,9 @@ def get_supported_components( """ if self.url is None: raise ValueError("Unexpected value None for self.url") + cached = self.props.get(cdav.SupportedCalendarComponentSet.tag) if use_cached else None + if cached: + return self.client._value_or_coroutine(list(cached)) if self.is_async_client: return self._async_get_supported_components(with_fallback) props = [cdav.SupportedCalendarComponentSet()] diff --git a/changes/+listing-props.changed.md b/changes/+listing-props.changed.md new file mode 100644 index 00000000..e15ed041 --- /dev/null +++ b/changes/+listing-props.changed.md @@ -0,0 +1 @@ +`get_calendars()` keeps every property the calendar-list PROPFIND answered in each calendar's `props`, not just the display name. That listing has always asked for `supported-calendar-component-set`, `getctag` and `calendar-color`, then thrown them away, so a client wanting a calendar's component set sent one more PROPFIND per calendar: 268 s against 6 s for 469 calendars on a Synology server. `get_supported_components(use_cached=True)` answers from that set without asking the server. A property the server answered 404 is left out, so it is still fetched when asked for. Cached reads (`get_property(..., use_cached=True)`) of `getctag` and `calendar-color` now answer the listing-time value instead of asking. diff --git a/tests/test_caldav_unit.py b/tests/test_caldav_unit.py index 6b952809..a15eec8d 100755 --- a/tests/test_caldav_unit.py +++ b/tests/test_caldav_unit.py @@ -1146,6 +1146,68 @@ def test_get_calendars(self): calendar_home_set = CalendarSet(client, url="/dav/testuser%40example.com/") assert len(calendar_home_set.get_calendars()) == 1 + def test_get_calendars_keeps_the_listed_properties(self): + """ + The calendar-list PROPFIND asks for the component set and the ctag + too; each Calendar keeps what was answered in its props, so a client + needs no second PROPFIND per calendar. A property answered 404 is + left out, so it is still fetched when asked for. + """ + xml = """ + + + /dav/user/tasks/ + + HTTP/1.1 200 OK + + + Tasks + + ctag-1 + + + + + /dav/user/plain/ + + HTTP/1.1 200 OK + + + + + + HTTP/1.1 404 Not Found + + + + + + + +""" + sccs = cdav.SupportedCalendarComponentSet.tag + client = MockedDAVClient(xml) + from_set = CalendarSet(client, url="/dav/user/").get_calendars() + listing = client.propfind("/dav/user/", props=client.CALENDAR_LIST_PROPS, depth=1) + from_client = client._build_calendars_from_propfind(listing) + for tasks, plain in (from_set, from_client): + assert tasks.props[sccs] == ["VTODO"] + assert tasks.props["{http://calendarserver.org/ns/}getctag"] == "ctag-1" + assert tasks.props[dav.DisplayName.tag] == "Tasks" + assert sccs not in plain.props + assert dav.DisplayName.tag not in plain.props + + ## use_cached answers from the listing; without it, or with nothing + ## listed, the server is asked as before + tasks, plain = from_set + with mock.patch.object(client, "request", side_effect=AssertionError("asked")): + assert tasks.get_supported_components(use_cached=True) == ["VTODO"] + with mock.patch.object(client, "request", wraps=client.request) as request: + tasks.get_supported_components() + plain.get_supported_components(use_cached=True) + assert request.call_count == 2 + def test_get_calendars_client_url_is_calendar_without_home_set(self): """ No calendar-home-set and no calendars below the principal: the From 75f6e7d3a83040a3a04504973460540d59c4d1f6 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Fri, 20 Nov 2026 19:15:10 +0100 Subject: [PATCH 8/8] feat: hint calendars a listing names but lacks Bedework 5 lists a tasks/ calendar in the calendar home, display name and component set included, that answers 404 when asked directly. A client taking calendars from the listing alone, as the listing's properties now allow, would hand it out to fail on use. The new feature propfind.listed-members-exist records that, broken for Bedework 5 (3.10 lists no such calendar), so such a client can ask each listed calendar first only where it is needed. Prompt: so let's go for yet another caldav compatibility hint on the ghost collections Assisted-By: Claude Opus 5.5 Reviewed-by: Tobias Brox --- caldav/compatibility_hints.py | 9 +++++++++ changes/+listed-members-exist.added.md | 1 + 2 files changed, 10 insertions(+) create mode 100644 changes/+listed-members-exist.added.md diff --git a/caldav/compatibility_hints.py b/caldav/compatibility_hints.py index e0a47a5c..c868cf61 100644 --- a/caldav/compatibility_hints.py +++ b/caldav/compatibility_hints.py @@ -305,6 +305,11 @@ class FeatureSet: "default": {"support": "full"}, "links": ["https://datatracker.ietf.org/doc/html/rfc3744#section-2", "https://datatracker.ietf.org/doc/html/rfc4918#section-9.1"], }, + "propfind.listed-members-exist": { + "description": "Every calendar a Depth: 1 PROPFIND of the calendar home lists is there: a PROPFIND of its own does not answer 404. RFC 4918 section 9.1 has a Depth: 1 PROPFIND report the members of the collection, so 'broken' is a listing naming a calendar that is not there - Bedework 5 lists a tasks/ calendar, display name and component set and all, that answers 404 when asked directly. A client that takes the listing's properties as they are hands such a calendar out, to fail when used; where this is broken, it asks each listed calendar first.", + "default": {"support": "full"}, + "links": ["https://datatracker.ietf.org/doc/html/rfc4918#section-9.1"], + }, "create-calendar.with-supported-component-types": { "description": "A MKCALENDAR naming a supported-calendar-component-set gives a calendar with that set. RFC 4791 section 5.3.1.1 has a server that cannot set a property answer 207 with 403 or 409 for it and create nothing; 'unsupported' means the calendar was created with another set (reported as another set, or not reported while an object outside the requested set can be saved to it) - Bedework 5 answers the property '200 ok' and makes a VEVENT-only calendar. When 'ungraceful', the MKCALENDAR request itself fails when a component set is specified. Whether the server then obeys the set it reports is supported-components.honoured.", "default": {"support": "full"}, @@ -2208,6 +2213,10 @@ def __getattr__(name: str) -> Any: "create-calendar.auto": {"support": "unsupported"}, "create-calendar.set-displayname": {"support": "full"}, "create-calendar.stable-url": {"support": "full"}, + ## Found 2026-11-20 on the docker image: the calendar home's listing + ## names tasks/ with a display name and ['VTODO'], and a PROPFIND of + ## tasks/ answers 404. Bedework 3.10 lists no such calendar. + "propfind.listed-members-exist": {"support": "broken", "behaviour": "lists a tasks/ calendar that answers 404"}, ## Not RFC properties; Bedework stores the Apple colour but not the order. "calendar-color": {"support": "full"}, "calendar-order": {"support": "unsupported"}, diff --git a/changes/+listed-members-exist.added.md b/changes/+listed-members-exist.added.md new file mode 100644 index 00000000..08036cbd --- /dev/null +++ b/changes/+listed-members-exist.added.md @@ -0,0 +1 @@ +New compatibility feature `propfind.listed-members-exist`: every calendar the calendar home's listing names is there. Bedework 5 lists a `tasks/` calendar that answers 404, which its profile now records as broken, so a client that takes calendars and their properties from the listing alone knows where to check each one first.