Fix: free-busy REPORT always fails when max_freebusy_occurrence is 0
free_busy_report() explicitly handles [reporting] max_freebusy_occurrence = 0
as "limit disabled" when fetching occurrences (n=0 lets time_range_fill
return all occurrences), but the subsequent limit check
'len(occurrences) >= max_occurrence' is trivially true for
max_occurrence == 0, so every free-busy query on a non-empty calendar
raised ValueError ("FREEBUSY occurrences limit of 0 hit") and was
answered with HTTP 400.
Skip the limit check when the limit is disabled, consistent with how
xml_report() treats the same setting ('if max_occurrence and ...').
Behavior for positive limits is unchanged.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -133,7 +133,7 @@ def free_busy_report(base_prefix: str, path: str, xml_request: Optional[ET.Eleme
|
||||
time_range_element,
|
||||
"VEVENT",
|
||||
n=n_occurrences)
|
||||
if len(occurrences) >= max_occurrence:
|
||||
if max_occurrence > 0 and len(occurrences) >= max_occurrence:
|
||||
raise ValueError("FREEBUSY occurrences limit of {} hit"
|
||||
.format(max_occurrence))
|
||||
|
||||
|
||||
@@ -2232,6 +2232,18 @@ permissions: RrWw""")
|
||||
<C:time-range start="20130901T140000Z" end="20130908T220000Z"/>
|
||||
</C:free-busy-query>""", 400, is_xml=False)
|
||||
|
||||
# Test max_freebusy_occurrence set to 0 (limit disabled)
|
||||
self.configure({"reporting": {"max_freebusy_occurrence": 0}})
|
||||
code, responses = self.report(calendar_path, """\
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<C:free-busy-query xmlns:C="urn:ietf:params:xml:ns:caldav">
|
||||
<C:time-range start="20130901T140000Z" end="20130908T220000Z"/>
|
||||
</C:free-busy-query>""", 200, is_xml=False)
|
||||
assert len(responses) == 1
|
||||
vcalendar = list(responses.values())[0]
|
||||
assert isinstance(vcalendar, vobject.base.Component)
|
||||
assert len(vcalendar.vfreebusy_list) == 3
|
||||
|
||||
def _report_sync_token(
|
||||
self, calendar_path: str, sync_token: Optional[str] = None, **kwargs
|
||||
) -> Tuple[str, RESPONSES]:
|
||||
|
||||
Reference in New Issue
Block a user