{"record":{"id":"34b9f74ef726dd92","repo":"laurent22/joplin","slug":"cannot-find-s-34b9f7","errorCode":null,"errorMessage":"Cannot find \"%s\".","messagePattern":"Cannot find \"(.+?)\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/command-restore.ts","lineNumber":19,"sourceCode":"import BaseCommand from './base-command';\nimport app from './app';\nimport { _ } from '@joplin/lib/locale';\nimport restoreItems from '@joplin/lib/services/trash/restoreItems';\n\nclass Command extends BaseCommand {\n\tpublic override usage() {\n\t\treturn 'restore <pattern>';\n\t}\n\n\tpublic override description() {\n\t\treturn _('Restore the items matching <pattern> from the trash.');\n\t}\n\n\tpublic override async action(args: { pattern: string }) {\n\t\tconst pattern = args['pattern'];\n\n\t\tconst items = await app().loadItems('folderOrNote', pattern);\n\t\tif (!items.length) throw new Error(_('Cannot find \"%s\".', pattern));\n\n\t\tconst ids = items.map(n => n.id);\n\t\tawait restoreItems(items[0].type_, ids, { useRestoreFolder: true });\n\t}\n}\n\nmodule.exports = Command;\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/command-restore.ts#L1-L27","documentation":"Thrown by `restore <pattern>` when `app().loadItems('folderOrNote', pattern)` returns an empty array. loadItems('folderOrNote', ...) tries folders then notes by exact title, full id, partial id >=2 chars. The command then calls `restoreItems(items[0].type_, ids, { useRestoreFolder: true })`. If the pattern matches nothing in the trash (or nothing at all), the array is empty.","triggerScenarios":"Pattern matches no trashed item; typo; partial id <2 chars; item was never deleted (so it isn't in trash); item already purged from trash by the revision/trash retention.","commonSituations":"Trying to restore by a title that exists only as a live (non-deleted) item; trash auto-emptyed; wrong partial id.","solutions":["List trash contents (in the GUI, or query the `notes`/`folders` tables where `deleted_time > 0`) to find exact titles/ids","Use the full or short id of the trashed item","Confirm the item is actually in trash and not already permanently purged"],"exampleFix":"// before\njoplin restore \"Old Note\"   // throws if not in trash or typo\n\n// after\n# find the trashed item's id (GUI trash view, or DB query), then:\njoplin restore <note-id>","handlingStrategy":"validation","validationCode":"import app from './app';\n\nasync function resolveTrashItems(pattern: string) {\n  const items = await app().loadItems('folderOrNote', pattern);\n  if (!items.length) throw new Error(`Cannot find \"${pattern}\" in trash. Verify trash contents or use the id.`);\n  // sanity: caller should only feed actually-deleted items\n  const allTrashed = items.every(i => !!(i as any).deleted_time);\n  if (!allTrashed) throw new Error('Some matched items are not in trash.');\n  return items;\n}","typeGuard":"const isTrashCandidate = (i: any): boolean =>\n  !!i?.id && typeof i.deleted_time === 'number' && i.deleted_time > 0;","tryCatchPattern":null,"preventionTips":["Confirm items are actually in trash before calling restore","Use full ids for trashed items (titles may collide with live items)","Watch trash retention settings — purged items cannot be restored"],"tags":["cli","restore","trash","lookup","validation"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}