<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Bug Report -  calendar-multiget returns the first requested event twice, matching duplicates in Apple Calendar]]></title><description><![CDATA[<h1>Calendar 1.12.0: calendar-multiget returns the first requested event twice, matching duplicates in Apple Calendar</h1>
<p dir="auto">After migrating from Radicale to Cloudron Calendar, I noticed duplicate events in the native macOS Calendar app and subsequently in the native iOS Calendar app. The same events appear only once in the Cloudron web calendar and in eM Client on macOS.</p>
<p dir="auto">An investigation identified a reproducible server-side bug in <code>calendar-multiget</code>: the first requested event resource is included twice in the response. The resulting duplication pattern matches the macOS calendar export exactly.</p>
<h2>Environment</h2>
<ul>
<li>Cloudron: <strong>10.1.5</strong></li>
<li>Calendar app: <strong>1.12.0</strong></li>
<li>Docker image: <code>cloudron/io.cloudron.calendar:202610170836060000</code></li>
<li>Build commit: <code>469f9bfa59d5dacf3c3de6071b9305b758edf14c</code></li>
<li>Affected clients: native Calendar on <strong>macOS 27.0.1</strong> and <strong>iOS 27.0.1</strong></li>
<li>Client connection: <strong>CalDAV</strong></li>
</ul>
<p dir="auto">The Radicale installation has been deprovisioned, and all devices have been switched to the new calendar server. The example event was probably created before the migration, but this is not certain.</p>
<h2>Observed data</h2>
<p dir="auto">The published ICS feed and an export of the affected calendar from macOS Calendar were compared:</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Measurement</th>
<th style="text-align:right">Cloudron ICS feed</th>
<th style="text-align:right">macOS Calendar export</th>
</tr>
</thead>
<tbody>
<tr>
<td>VEVENT components</td>
<td style="text-align:right">1,149</td>
<td style="text-align:right">1,172</td>
</tr>
<tr>
<td>Distinct event UIDs</td>
<td style="text-align:right">1,149</td>
<td style="text-align:right">1,149</td>
</tr>
<tr>
<td>UIDs occurring twice</td>
<td style="text-align:right">0</td>
<td style="text-align:right">23</td>
</tr>
<tr>
<td>UIDs absent from the other export</td>
<td style="text-align:right">0</td>
<td style="text-align:right">0</td>
</tr>
</tbody>
</table>
<p dir="auto">The affected example is a non-recurring event. Both copies in the Apple export are identical, including their UID, start/end times and other properties. The UI shows both under the same calendar name and colour.</p>
<p dir="auto">Across the full Apple export:</p>
<ul>
<li>Each of the 23 duplicated UIDs occurs exactly twice.</li>
<li>None of these copies has a <code>RECURRENCE-ID</code>, so these are not ordinary master/exception pairs. One affected UID belongs to an entire recurring series.</li>
<li>After unfolding iCalendar lines, 17 pairs are completely identical. The other six differ only in the identifiers of their embedded <code>VALARM</code> components; their event data is otherwise identical.</li>
</ul>
<p dir="auto">This establishes that the duplication is present in Apple's exported event data, rather than only in the visual calendar view.</p>
<h2>Cause in the shipped code</h2>
<p dir="auto">The source was obtained from the source layer of the exact installed public Docker image, without running the image. Its SHA-256 was verified against the image manifest:</p>
<p dir="auto"><code>sha256:7c12598ce3c7396a3e96bd50470e4eaecb745c66f7f1b6633fefe9cc9ab5a465</code></p>
<p dir="auto">In <code>src/routes/caldav.js</code>, <code>extractHrefs()</code> at lines 293–306 contains:</p>
<pre><code class="language-js">if (obj.href) hrefs.push(Array.isArray(obj.href) ? obj.href[0] : obj.href);
Object.values(obj).forEach(walk);
</code></pre>
<p dir="auto">The first line explicitly adds the first <code>href</code>. The recursive traversal on the next line then adds every <code>href</code>, including that first one again. This also happens when only one resource is requested.</p>
<p dir="auto">The <code>calendar-multiget</code> branch of <code>handleReport()</code> at lines 225–242 maps the resulting list directly to event responses without deduplicating it. Consequently, the response includes the same resource URL and event UID twice.</p>
<p dir="auto">The <code>calendar-query</code> branch uses a different path. The public ICS export also reads the event collection directly and does not call <code>extractHrefs()</code>.</p>
<h2>Isolated reproduction</h2>
<p dir="auto">The original extraction function and REPORT handler were tested with the exact XML parser version from the shipped lockfile: <strong>fast-xml-parser 5.11.2</strong>. Database access and ICS serialization were replaced with synthetic data. No production CalDAV requests or calendar writes were needed.</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="text-align:right">Requested resources via calendar-multiget</th>
<th style="text-align:right">Successful event responses</th>
<th style="text-align:right">Distinct event resources</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right">1</td>
<td style="text-align:right">2</td>
<td style="text-align:right">1</td>
</tr>
<tr>
<td style="text-align:right">2</td>
<td style="text-align:right">3</td>
<td style="text-align:right">2</td>
</tr>
<tr>
<td style="text-align:right">49</td>
<td style="text-align:right">50</td>
<td style="text-align:right">49</td>
</tr>
<tr>
<td style="text-align:right">50</td>
<td style="text-align:right">51</td>
<td style="text-align:right">50</td>
</tr>
</tbody>
</table>
<p dir="auto">In each case, only the first requested resource is returned twice. A control test through the original <code>calendar-query</code> branch returns exactly <strong>50 responses for 50 events</strong>, with no duplicated resources.</p>
<p dir="auto">Here is a minimal reproduction of the extraction bug. It uses the unchanged helper from the shipped source and the same parser options. Save it as <code>reproduce.cjs</code> in a directory containing <code>fast-xml-parser@5.11.2</code>, then run <code>node reproduce.cjs</code>. It uses synthetic URLs and makes no network requests.</p>
<pre><code class="language-js">const assert = require('node:assert/strict');
const { XMLParser } = require('fast-xml-parser');

// Copied unchanged from src/routes/caldav.js in Calendar 1.12.0,
// commit 469f9bfa59d5dacf3c3de6071b9305b758edf14c.
function extractHrefs(multigetEl) {
  const hrefs = [];
  const walk = (obj) =&gt; {
    if (!obj) return;
    if (typeof obj === 'string' &amp;&amp; obj.trim()) hrefs.push(obj.trim());
    if (Array.isArray(obj)) obj.forEach(walk);
    else if (typeof obj === 'object') {
      if (obj.href) hrefs.push(Array.isArray(obj.href) ? obj.href[0] : obj.href);
      Object.values(obj).forEach(walk);
    }
  };
  walk(multigetEl);
  return hrefs;
}

const parser = new XMLParser({
  ignoreAttributes: false,
  attributeNamePrefix: '@_',
  removeNSPrefix: true
});

for (const count of [1, 2, 49, 50]) {
  const requested = Array.from({ length: count },
    (_, i) =&gt; `/users/test/calendars/1/event-${i}.ics`);
  const body = `&lt;C:calendar-multiget
    xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav"&gt;
    &lt;D:prop&gt;&lt;D:getetag/&gt;&lt;C:calendar-data/&gt;&lt;/D:prop&gt;
    ${requested.map(href =&gt; `&lt;D:href&gt;${href}&lt;/D:href&gt;`).join('')}
  &lt;/C:calendar-multiget&gt;`;
  const extracted = extractHrefs(parser.parse(body)['calendar-multiget']);

  assert.equal(extracted.length, count + 1);
  assert.equal(new Set(extracted).size, count);
  assert.equal(extracted.filter(href =&gt; href === requested[0]).length, 2);
  for (const href of requested.slice(1)) {
    assert.equal(extracted.filter(value =&gt; value === href).length, 1);
  }
  console.log(`Requested: ${count}; extracted: ${extracted.length}; unique: ${new Set(extracted).size}`);
}
</code></pre>
<p dir="auto">Expected output from the current implementation:</p>
<pre><code class="language-text">Requested: 1; extracted: 2; unique: 1
Requested: 2; extracted: 3; unique: 2
Requested: 49; extracted: 50; unique: 49
Requested: 50; extracted: 51; unique: 50
</code></pre>
<h2>Match with the real export</h2>
<p dir="auto">The Apple export can be divided into 23 consecutive groups: one group of 50 components containing 49 distinct UIDs, followed by 22 groups of 51 components containing 50 distinct UIDs each. Each group has exactly one duplicated UID, with no UIDs shared between groups.</p>
<p dir="auto">This strongly suggests requests containing up to 50 resources. The actual request sizes were not captured on the network, so that part remains an inference.</p>
<p dir="auto">Simulating 22 requests for 50 resources and one request for 49 resources produces:</p>
<ul>
<li>Requested: <code>22 × 50 + 49 = 1,149</code> events.</li>
<li>Returned: <code>22 × 51 + 50 = 1,172</code> event responses.</li>
<li>Additional copies: <strong>23</strong>.</li>
</ul>
<p dir="auto">These figures exactly match the Cloudron feed and Apple export.</p>
<h2>Scope and remaining uncertainty</h2>
<p dir="auto">The server bug is reproduced, and the macOS export provides strong evidence that it explains the observed duplicates. A trace of the actual production CalDAV exchange was not collected, so the precise client/server sequence has not been independently confirmed.</p>
<p dir="auto">The same behaviour is observed in iOS Calendar, but no separate iOS export or trace was analysed. The same cause is plausible there, rather than separately proven.</p>
<p dir="auto">The Cloudron web UI and published ICS feed bypass the affected code path. Why eM Client shows only one copy has not been verified: it may use a different query type or deduplicate repeated resources. Its network traffic was not examined.</p>
<p dir="auto">The migration is not required to trigger the code defect, as the synthetic reproduction demonstrates. A full sync after migration may have exposed it, but that timing is not established.</p>
<p dir="auto">This report covers diagnosis only. No production events, accounts or server settings were changed during the investigation.</p>
<p dir="auto"><em><strong>Disclosure:</strong> This report was prepared with the assistance of OpenAI Codex for source-code analysis, comparison of calendar exports, and an isolated reproduction using synthetic data. The reported symptoms were observed on my devices. The server-side defect was reproduced locally; the production CalDAV traffic was not captured.</em></p>
]]></description><link>https://forum.cloudron.io/topic/16160/bug-report-calendar-multiget-returns-the-first-requested-event-twice-matching-duplicates-in-apple-calendar</link><generator>RSS for Node</generator><lastBuildDate>Fri, 20 Nov 2026 19:02:13 GMT</lastBuildDate><atom:link href="https://forum.cloudron.io/topic/16160.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 20 Oct 2026 07:02:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bug Report -  calendar-multiget returns the first requested event twice, matching duplicates in Apple Calendar on Tue, 20 Oct 2026 10:05:14 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for the report. This is now fixed in latest package release.</p>
]]></description><link>https://forum.cloudron.io/post/131270</link><guid isPermaLink="true">https://forum.cloudron.io/post/131270</guid><dc:creator><![CDATA[nebulon]]></dc:creator><pubDate>Tue, 20 Oct 2026 10:05:14 GMT</pubDate></item></channel></rss>