{"record":{"id":"0f2a168af7b3e947","repo":"laurent22/joplin","slug":"cannot-find-s-0f2a16","errorCode":null,"errorMessage":"Cannot find \"%s\".","messagePattern":"Cannot find \"(.+?)\"\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/command-export.ts","lineNumber":37,"sourceCode":"\t\tconst formats = service\n\t\t\t.modules()\n\t\t\t.filter(m => m.type === 'exporter' && m.format !== 'html')\n\t\t\t.map(m => m.format + (m.description ? ` (${m.description})` : ''));\n\n\t\treturn [['--format <format>', _('Destination format: %s', formats.join(', '))], ['--note <note>', _('Exports only the given note.')], ['--notebook <notebook>', _('Exports only the given notebook.')]];\n\t}\n\n\tpublic override async action(args: { path: string; options: { format?: string; note?: string; 'notebook'?: string } }) {\n\t\tconst exportOptions: ExportOptions = {};\n\t\texportOptions.path = args.path;\n\n\t\texportOptions.format = args.options.format ? args.options.format as ExportModuleOutputFormat : ExportModuleOutputFormat.Jex;\n\n\t\tif (exportOptions.format === 'html') throw new Error('HTML export is not supported. Please use the desktop application.');\n\n\t\tif (args.options.note) {\n\t\t\tconst notes = await app().loadItems(ModelType.Note, args.options.note, { parent: app().currentFolder() });\n\t\t\tif (!notes.length) throw new Error(_('Cannot find \"%s\".', args.options.note));\n\t\t\texportOptions.sourceNoteIds = notes.map(n => n.id);\n\t\t} else if (args.options.notebook) {\n\t\t\tconst folders = await app().loadItems(ModelType.Folder, args.options.notebook);\n\t\t\tif (!folders.length) throw new Error(_('Cannot find \"%s\".', args.options.notebook));\n\t\t\texportOptions.sourceFolderIds = folders.map(n => n.id);\n\t\t}\n\n\t\tconst service = InteropService.instance();\n\t\tconst result = await service.export(exportOptions);\n\n\t\tresult.warnings.map(w => this.stdout(w));\n\t}\n}\n\nmodule.exports = Command;\n","sourceCodeStart":19,"sourceCodeEnd":53,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/command-export.ts#L19-L53","documentation":"Thrown by `export <path> --note <note>` when `app().loadItems(ModelType.Note, args.options.note, { parent: app().currentFolder() })` returns an empty array. The lookup is scoped to the current notebook via the `parent` option, so a note that exists elsewhere is invisible here. loadItems resolves by exact title, full id, or partial id (>=2 chars); an empty result means none matched within the current folder.","triggerScenarios":"Passing `--note` with a title that doesn't exist in the *current* notebook (it does exist in another); a typo; a partial id shorter than 2 chars; a note that was deleted or moved to trash; passing a note id when no notebook is selected and `currentFolder()` is null (loadItems throws a different error first).","commonSituations":"Exporting a note by title when the active notebook changed since `ls`; copy-paste of a note id with trailing whitespace; partial-id matches that are too short to be considered.","solutions":["Run `joplin ls` and copy the exact title or full id of the target note","Switch to the notebook containing the note first: `joplin use <notebook>`, then re-run export with `--note`","Use the full note id rather than a partial id (<2 chars never resolves)","If exporting regardless of notebook, use `--notebook <name>` instead and drop `--note`"],"exampleFix":"// before\njoplin use WrongBook\njoplin export out.md --note \"Meeting\"   // throws: Cannot find \"Meeting\".\n\n// after\njoplin use Work\njoplin export out.md --note \"Meeting\"\n// or export by id regardless of selection:\njoplin export out.md --note <full-note-id>","handlingStrategy":"validation","validationCode":"import app from './app';\nimport { ModelType } from '@joplin/lib/BaseModel';\n\nasync function resolveNoteForExport(noteRef: string) {\n  if (!app().currentFolder()) throw new Error('Select a notebook first (`use <notebook>`).');\n  const notes = await app().loadItems(ModelType.Note, noteRef, { parent: app().currentFolder() });\n  if (!notes.length) throw new Error(`Cannot find \"${noteRef}\" in notebook \"${app().currentFolder().title}\". Use ls to verify.`);\n  return notes;\n}\n\n// use this before building ExportOptions","typeGuard":"const hasNoteMatches = (notes: unknown[]): notes is { id: string }[] =>\n  Array.isArray(notes) && notes.length > 0;","tryCatchPattern":"try {\n  await cli.execCommand(['export', path, '--note', noteRef]);\n} catch (e) {\n  if (e.message.startsWith('Cannot find')) {\n    // surface a helpful hint, retry with `use` or fall back to full export\n    console.error(e.message, '— verify the note is in the current notebook.');\n  } else throw e;\n}","preventionTips":["Always resolve the note via `loadItems` and check length before passing to export","Prefer note ids over titles for scripted exports (titles can be renamed)","Remember the --note lookup is parent-scoped to currentFolder — select the right notebook first"],"tags":["cli","export","note-lookup","validation"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}