{"record":{"id":"54d3fd85329cdd48","repo":"laurent22/joplin","slug":"cannot-find-s-54d3fd","errorCode":null,"errorMessage":"Cannot find \"%s\".","messagePattern":"Cannot find \"(.+?)\"\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/command-import.ts","lineNumber":37,"sourceCode":"\n\tpublic override options() {\n\t\tconst service = InteropService.instance();\n\t\tconst formats = service\n\t\t\t.modules()\n\t\t\t.filter(m => m.type === 'importer')\n\t\t\t.map(m => m.format);\n\n\t\treturn [\n\t\t\t['--format <format>', _('Source format: %s', ['auto'].concat(unique(formats)).join(', '))],\n\t\t\t['-f, --force', _('Do not ask for confirmation.')],\n\t\t\t['--output-format <output-format>', _('Output format: %s', 'md, html')],\n\t\t];\n\t}\n\n\tpublic override async action(args: { path: string; 'notebook'?: string; options: { format?: string; outputFormat?: string } }) {\n\t\tlet destinationFolder = await app().loadItem(ModelType.Folder, args.notebook);\n\n\t\tif (args.notebook && !destinationFolder) throw new Error(_('Cannot find \"%s\".', args.notebook));\n\n\t\tif (!destinationFolder) destinationFolder = await Folder.defaultFolder();\n\n\t\tconst importOptions: ImportOptions = {};\n\t\timportOptions.path = args.path;\n\t\timportOptions.format = args.options.format ? args.options.format : 'auto';\n\t\timportOptions.destinationFolderId = destinationFolder ? destinationFolder.id : null;\n\n\t\tlet lastProgress = '';\n\n\t\t// onProgress/onError supported by Enex import only\n\n\t\timportOptions.onProgress = progressState => {\n\t\t\tconst line = [];\n\t\t\tline.push(_('Found: %d.', progressState.loaded));\n\t\t\tline.push(_('Created: %d.', progressState.created));\n\t\t\tif (progressState.updated) line.push(_('Updated: %d.', progressState.updated));\n\t\t\tif (progressState.skipped) line.push(_('Skipped: %d.', progressState.skipped));","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/command-import.ts#L19-L55","documentation":"Thrown by `import <path> [notebook]` when a notebook argument was supplied (`args.notebook` truthy) but `app().loadItem(ModelType.Folder, args.notebook)` returned null. The guard is `if (args.notebook && !destinationFolder)`, so omitting the notebook arg entirely falls through to `Folder.defaultFolder()` instead of throwing. Lookup is global (not parent-scoped) for folders.","triggerScenarios":"Passing a notebook name that doesn't exist; typo; partial id <2 chars; expecting import to auto-create the destination notebook (it does not).","commonSituations":"First-time import workflow where the user assumes the destination notebook is created on demand; renamed target notebook; copy-paste error in scripts.","solutions":["Create the destination notebook first: `joplin mkbook <name>`, then re-run import with that name","Omit the notebook argument entirely to import into the most recently created notebook (Folder.defaultFolder ordering)","Verify the title with `joplin ls /` or use the short notebook id"],"exampleFix":"// before\njoplin import notes.enex Incoming   // throws if \"Incoming\" doesn't exist\n\n// after\njoplin mkbook Incoming\njoplin import notes.enex Incoming\n// or omit notebook to use default:\njoplin import notes.enex","handlingStrategy":"validation","validationCode":"import app from './app';\nimport Folder from '@joplin/lib/models/Folder';\nimport { ModelType } from '@joplin/lib/BaseModel';\n\nasync function resolveImportDestination(notebookRef?: string) {\n  if (!notebookRef) {\n    const def = await Folder.defaultFolder();\n    if (!def) throw new Error('No notebooks exist. Run `mkbook <name>` before importing.');\n    return def;\n  }\n  const folder = await app().loadItem(ModelType.Folder, notebookRef);\n  if (!folder) throw new Error(`Cannot find notebook \"${notebookRef}\". Create it with \\`mkbook\\` first.`);\n  return folder;\n}","typeGuard":"const isFolder = (f: any): f is { id: string; title: string } =>\n  !!f && typeof f.id === 'string';","tryCatchPattern":null,"preventionTips":["Pre-create import target notebooks with `mkbook`","Omit the notebook arg to fall back to defaultFolder() when you don't care","Verify with `ls /` before scripted imports"],"tags":["cli","import","notebook-lookup","validation"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}