{"record":{"id":"5b3743ff6f611ebc","repo":"laurent22/joplin","slug":"cannot-find-s-5b3743","errorCode":null,"errorMessage":"Cannot find \"%s\".","messagePattern":"Cannot find \"(.+?)\"\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/command-attach.ts","lineNumber":21,"sourceCode":"import { _ } from '@joplin/lib/locale';\nimport { ModelType } from '@joplin/lib/BaseModel';\nimport shim from '@joplin/lib/shim';\n\nclass Command extends BaseCommand {\n\tpublic override usage() {\n\t\treturn 'attach <note> <file>';\n\t}\n\n\tpublic override description() {\n\t\treturn _('Attaches the given file to the note.');\n\t}\n\n\tpublic override async action(args: { note: string; file: string }) {\n\t\tconst title = args['note'];\n\n\t\tconst note = await app().loadItem(ModelType.Note, title, { parent: app().currentFolder() });\n\t\tthis.encryptionCheck(note);\n\t\tif (!note) throw new Error(_('Cannot find \"%s\".', title));\n\n\t\tconst localFilePath = args['file'];\n\n\t\tawait shim.attachFileToNote(note, localFilePath);\n\t}\n}\n\nmodule.exports = Command;\n","sourceCodeStart":3,"sourceCodeEnd":30,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/command-attach.ts#L3-L30","documentation":"The 'attach' command loads the target note by title via app().loadItem scoped to the current notebook, runs encryptionCheck, then checks for null and throws 'Cannot find' if the note does not exist. The message is i18n-translated.","triggerScenarios":"Running 'attach <note> <file>' where <note> does not match any note title or id in the current notebook.","commonSituations":"Typo in the note title; note is in a different notebook than the current one; note not yet synced; note was deleted.","solutions":["Verify the exact title/id with 'ls'.","Switch to the correct notebook with 'use <notebook>'.","Sync to pull missing notes.","Use the note id if the title is ambiguous."],"exampleFix":"# before\n#   joplin attach \"shoping\" list.txt   # typo -> Cannot find\n# after\n#   joplin attach \"shopping\" list.txt","handlingStrategy":"validation","validationCode":"const note = await app().loadItem(ModelType.Note, title, { parent: app().currentFolder() });\nif (!note) {\n  console.error(`Note not found: ${title}`);\n  return;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await shim.attachFileToNote(note, localFilePath);\n} catch (e) {\n  if (/Cannot find/.test(e.message)) console.error(e.message);\n}","preventionTips":["Verify the note title/id with 'ls' before attaching.","Run 'use <notebook>' to ensure the right notebook is current.","Sync before attaching to recently created remote notes."],"tags":["cli","attach-command","item-lookup","i18n"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}