laurent22/joplin · error · Error

Cannot find "%s".

Error message

Cannot find "%s".

What it means

App.loadItemOrFail is a thin wrapper: it calls loadItem and, if the result is null, throws 'Cannot find'. It is used by commands that require the item to exist. The message is i18n-translated via _().

Source

Thrown at packages/app-cli/app/app.ts:81

			// 	answers[i + 1] = output[i].title;
			// }

			// Not really useful with new UI?
			throw new Error(_('More than one item match "%s". Please narrow down your query.', pattern));

			// let msg = _('More than one item match "%s". Please select one:', pattern);
			// const response = await cliUtils.promptMcq(msg, answers);
			// if (!response) return null;

			// return output[response - 1];
		} else {
			return output.length ? output[0] : null;
		}
	}

	public async loadItemOrFail(type: FolderOrNoteType, pattern: string) {
		const output = await this.loadItem(type, pattern);
		if (!output) throw new Error(_('Cannot find "%s".', pattern));
		return output;
	}

	public async loadItems(type: FolderOrNoteType, pattern: string, options: { parent?: FolderEntity } | null = null): Promise<(FolderEntity | NoteEntity)[]> {
		if (type === 'folderOrNote') {
			const folders: FolderEntity[] = await this.loadItems(ModelType.Folder, pattern, options);
			if (folders.length) return folders;
			return await this.loadItems(ModelType.Note, pattern, options);
		}

		pattern = pattern ? pattern.toString() : '';

		if (type === ModelType.Folder && (pattern === Folder.conflictFolderTitle() || pattern === Folder.conflictFolderId())) return [Folder.conflictFolder()];

		if (!options) options = {};

		const parent = options.parent ? options.parent : app().currentFolder();
		const ItemClass = BaseItem.itemClass(type);

View on GitHub (pinned to 2654b33620)

Solutions

  1. List items with 'ls' to verify the exact title or id.
  2. Check the current notebook with 'use' / switch to the right one.
  3. Sync to pull missing items.
  4. Use a partial id (>= 2 chars) if the title is hard to type.

Example fix

// before
//   const note = await app().loadItemOrFail(ModelType.Note, title);
// after
//   const note = await app().loadItem(ModelType.Note, title);
//   if (!note) { console.error(`Note not found: ${title}`); return; }
Defensive patterns

Strategy: validation

Validate before calling

const item = await app().loadItem(type, pattern);
if (!item) {
  console.error(`Item not found: ${pattern}`);
  return;
}

Try / catch

try {
  const item = await app().loadItemOrFail(type, pattern);
} catch (e) {
  if (/Cannot find/.test(e.message)) console.error(e.message);
}

Prevention

When it happens

Trigger: The supplied pattern matches no note or notebook — a typo in the title, a wrong notebook scope, or an item that has not synced yet.

Common situations: Typo in a note title on the command line; item lives in a different notebook than the current one; fresh device before initial sync; item was deleted.

Related errors


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