laurent22/joplin · error · Error

Multiple invitations found with the same ID

Error message

Multiple invitations found with the same ID

What it means

Thrown by `commandShareAcceptOrReject` when more than one Waiting invitation exists for the same folderId. This is a defensive guard: accepting/rejecting uses `invitations[0]`, so an ambiguous set could act on the wrong invitation. Rather than guess, the command refuses to proceed. The comment in source explicitly documents this as preventing wrong-invitation acceptance.

Source

Thrown at packages/app-cli/app/command-share.ts:225

					} else {
						this.stdout(`\t${_('None')}`);
					}
				}
			}
		};

		const commandShareAcceptOrReject = async (folderId: string, accept: boolean) => {
			await ShareService.instance().maintenance();

			const shareState = getShareState();
			const invitations = shareState.shareInvitations.filter(invitation => {
				return invitation.share.folder_id === folderId && invitation.status === ShareUserStatus.Waiting;
			});
			if (invitations.length === 0) throw new Error('No such invitation found');

			// If there are multiple invitations for the same folder, stop early to avoid
			// accepting the wrong invitation.
			if (invitations.length > 1) throw new Error('Multiple invitations found with the same ID');

			const invitation = invitations[0];

			this.stdout(accept ? _('Accepting share...') : _('Rejecting share...'));
			await invitationRespond(invitation.id, invitation.share.folder_id, invitation.master_key, accept);
		};

		const commandShareAccept = (folderId: string) => (
			commandShareAcceptOrReject(folderId, true)
		);

		const commandShareReject = (folderId: string) => (
			commandShareAcceptOrReject(folderId, false)
		);

		const commandShareDelete = async (folder: FolderEntity) => {
			const force = args.options.force;
			const ok = force ? true : await this.prompt(

View on GitHub (pinned to 2654b33620)

Solutions

  1. Run `:sync` again — a follow-up server reconciliation may collapse the duplicates.
  2. Run `share list` and inspect invitations; if a duplicate is visible, report it as a server/client bug with the folder id.
  3. As a workaround, reject first to clear Waiting entries, then ask the sender to re-invite once.
  4. Do not attempt to patch redux state manually unless you understand the share reducer.

Example fix

// before
if (invitations.length > 1) throw new Error('Multiple invitations found with the same ID');

// after - keep the guard but expose the duplicate ids for diagnostics
if (invitations.length > 1) throw new Error(`Multiple waiting invitations (${invitations.length}) for folder ${folderId}: ${invitations.map(i => i.id).join(', ')}`);
Defensive patterns

Strategy: try-catch

Validate before calling

if (invitations.length > 1) {
	// Surface as a data-integrity issue rather than silently picking [0].
	throw new Error(`Duplicate waiting invitations for folder ${folderId}: ${invitations.map(i => i.id).join(', ')}`);
}

Type guard

const hasUniqueWaitingInvitation = (invitations: ShareInvitation[], folderId: string): boolean =>
	invitations.filter(i => i.share.folder_id === folderId && i.status === ShareUserStatus.Waiting).length === 1;

Try / catch

try {
	await commandShareAccept(folderId);
} catch (e) {
	if (/Multiple invitations/.test(e.message)) { /* sync, report server bug, or reject-then-reinvite */ }
	else throw e;
}

Prevention

When it happens

Trigger: The redux `shareInvitations` array contains two or more entries with the same `share.folder_id` and `status === Waiting`. This is an unexpected server state — normally a folder has at most one outstanding invitation per recipient — and usually results from a server-side bug, a duplicate sync, or re-invitation after a rejected one that did not clear the old entry.

Common situations: Server bug producing duplicate invitations; sync replay that duplicated invitation records; re-inviting a user after a reject without cleaning the prior record.

Related errors


AI-assisted analysis of laurent22/joplin@2654b33620 (2026-08-12). Data as JSON: /api/errors/41e44f8cf196eff6. Report an issue: GitHub.