{"record":{"id":"97d2cfe9e5ddf1ad","repo":"nextcloud/server","slug":"calendar-is-not-shared-with-the-sharee","errorCode":null,"errorMessage":"Calendar is not shared with the sharee","messagePattern":"Calendar is not shared with the sharee","errorType":"http","errorClass":"ShareNotFound","httpStatus":400,"severity":"warning","filePath":"apps/dav/lib/CalDAV/Federation/CalendarFederationProvider.php","lineNumber":228,"sourceCode":"\n\t\tif ($calendarUrl === null || $calendarUrl === '') {\n\t\t\tthrow new BadRequestException([CalendarFederationNotifier::PROP_SYNC_CALENDAR_CALENDAR_URL]);\n\t\t}\n\n\t\ttry {\n\t\t\t$shareWith = $this->cloudIdManager->resolveCloudId($shareWithRaw);\n\t\t} catch (\\InvalidArgumentException $e) {\n\t\t\tthrow new ShareNotFound('Invalid sharee cloud id');\n\t\t}\n\n\t\t$calendars = $this->federatedCalendarMapper->findByRemoteUrl(\n\t\t\t$calendarUrl,\n\t\t\t'principals/users/' . $shareWith->getUser(),\n\t\t\t$sharedSecret,\n\t\t\tFederatedCalendarEntity::STATE_ACCEPTED,\n\t\t);\n\t\tif (empty($calendars)) {\n\t\t\tthrow new ShareNotFound('Calendar is not shared with the sharee');\n\t\t}\n\n\t\tforeach ($calendars as $calendar) {\n\t\t\t$this->jobList->add(FederatedCalendarSyncJob::class, [\n\t\t\t\tFederatedCalendarSyncJob::ARGUMENT_ID => $calendar->getId(),\n\t\t\t]);\n\t\t}\n\n\t\treturn [];\n\t}\n\n\t/**\n\t * @return array{0: CalendarFederationProtocolV1, 1: string, 2: string, 3: ?string, 4: int, 5: string}|null\n\t *                                                                                                          [parsed protocol, calendarUrl, displayName, color, access, components], or null when\n\t *                                                                                                          the envelope cannot be parsed (missing/unsupported version, parse error).\n\t */\n\tprivate function parseShare(ICloudFederationShare $share): ?array {\n\t\t$rawProtocol = $share->getProtocol();","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/nextcloud/server/blob/ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3/apps/dav/lib/CalDAV/Federation/CalendarFederationProvider.php#L210-L246","documentation":"OCP\\Share\\Exceptions\\ShareNotFound thrown by CalendarFederationProvider::handleSyncCalendarNotification() when FederatedCalendarMapper::findByRemoteUrl() returns nothing for the given calendarUrl, principals/users/<sharee>, sharedSecret and state STATE_ACCEPTED. All four conditions must match a stored federated calendar entity, so a mismatch in url, user, token/secret, or an unaccepted (pending/declined) share yields this error. Success instead queues FederatedCalendarSyncJob per matched calendar.","triggerScenarios":"Sending a SYNC_CALENDAR notification for a share that is still STATE_PENDING (invite not accepted); using a calendarUrl different from the one the share was created with; a sharedSecret that no longer matches the stored token; targeting a sharee user that does not own the federated calendar row.","commonSituations":"Sharer's server sends a sync ping before the sharee accepted; share re-sent which rotated the secret while the old notification was in flight; user renamed or the calendar re-shared under a new url; clock/ordering races between acceptance and first sync.","solutions":["Ensure the sharee has accepted the federated calendar (STATE_ACCEPTED) before sending SYNC_CALENDAR notifications.","Send the exact calendarUrl used when the share was created and the current sharedSecret from the share.","Re-check the stored entity via FederatedCalendarMapper (remote url, principal, token, state) when debugging.","Delay/retry the notification after the sharee accepts; treat ShareNotFound as 'not ready' rather than a hard failure."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// before notifying, confirm an accepted federated calendar exists for the tuple\n$calendars = $this->federatedCalendarMapper->findByRemoteUrl(\n    $calendarUrl,\n    'principals/users/' . $shareeUser,\n    $sharedSecret,\n    \\OCA\\DAV\\CalDAV\\Federation\\FederatedCalendarEntity::STATE_ACCEPTED,\n);\nif ($calendars === []) {\n    // share not accepted yet (or url/secret mismatch); skip the notification\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    $provider->notificationReceived('SYNC_CALENDAR', 'calendar', $notification);\n} catch (\\OCP\\Share\\Exceptions\\ShareNotFound $e) {\n    // share missing/pending/mismatched: re-check acceptance and current secret, then retry once\n}","preventionTips":["Only send SYNC_CALENDAR after the sharee accepted the share.","Keep the sharedSecret in lockstep with the latest re-share of the calendar.","Treat ShareNotFound as a state problem (pending/mismatch), not a transport failure; verify state before retrying."],"tags":["caldav","calendar","federation","share-not-found","sync","shared-secret"],"backgroundTag":"share-not-found","analyzedSha":"ecdeb153ffdf227235c9a7e2d13dbe0f9c817bc3","analyzedAt":"2026-08-17T01:36:13.386Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}