{"record":{"id":"31d389d7e1d99172","repo":"laurent22/joplin","slug":"cannot-find-s","errorCode":null,"errorMessage":"Cannot find \"%s\".","messagePattern":"Cannot find \"(.+?)\"\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/app.ts","lineNumber":81,"sourceCode":"\t\t\t// \tanswers[i + 1] = output[i].title;\n\t\t\t// }\n\n\t\t\t// Not really useful with new UI?\n\t\t\tthrow new Error(_('More than one item match \"%s\". Please narrow down your query.', pattern));\n\n\t\t\t// let msg = _('More than one item match \"%s\". Please select one:', pattern);\n\t\t\t// const response = await cliUtils.promptMcq(msg, answers);\n\t\t\t// if (!response) return null;\n\n\t\t\t// return output[response - 1];\n\t\t} else {\n\t\t\treturn output.length ? output[0] : null;\n\t\t}\n\t}\n\n\tpublic async loadItemOrFail(type: FolderOrNoteType, pattern: string) {\n\t\tconst output = await this.loadItem(type, pattern);\n\t\tif (!output) throw new Error(_('Cannot find \"%s\".', pattern));\n\t\treturn output;\n\t}\n\n\tpublic async loadItems(type: FolderOrNoteType, pattern: string, options: { parent?: FolderEntity } | null = null): Promise<(FolderEntity | NoteEntity)[]> {\n\t\tif (type === 'folderOrNote') {\n\t\t\tconst folders: FolderEntity[] = await this.loadItems(ModelType.Folder, pattern, options);\n\t\t\tif (folders.length) return folders;\n\t\t\treturn await this.loadItems(ModelType.Note, pattern, options);\n\t\t}\n\n\t\tpattern = pattern ? pattern.toString() : '';\n\n\t\tif (type === ModelType.Folder && (pattern === Folder.conflictFolderTitle() || pattern === Folder.conflictFolderId())) return [Folder.conflictFolder()];\n\n\t\tif (!options) options = {};\n\n\t\tconst parent = options.parent ? options.parent : app().currentFolder();\n\t\tconst ItemClass = BaseItem.itemClass(type);","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/app.ts#L63-L99","documentation":"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 _().","triggerScenarios":"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.","commonSituations":"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.","solutions":["List items with 'ls' to verify the exact title or id.","Check the current notebook with 'use' / switch to the right one.","Sync to pull missing items.","Use a partial id (>= 2 chars) if the title is hard to type."],"exampleFix":"// before\n//   const note = await app().loadItemOrFail(ModelType.Note, title);\n// after\n//   const note = await app().loadItem(ModelType.Note, title);\n//   if (!note) { console.error(`Note not found: ${title}`); return; }","handlingStrategy":"validation","validationCode":"const item = await app().loadItem(type, pattern);\nif (!item) {\n  console.error(`Item not found: ${pattern}`);\n  return;\n}","typeGuard":null,"tryCatchPattern":"try {\n  const item = await app().loadItemOrFail(type, pattern);\n} catch (e) {\n  if (/Cannot find/.test(e.message)) console.error(e.message);\n}","preventionTips":["Use the non-throwing loadItem when absence is a recoverable condition.","Verify titles with 'ls' before running commands that use loadItemOrFail.","Sync before operating on recently created remote items."],"tags":["cli","item-lookup","i18n"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}