{"record":{"id":"c934299271da99cc","repo":"laurent22/joplin","slug":"no-notebook-has-been-specified","errorCode":null,"errorMessage":"No notebook has been specified.","messagePattern":"No notebook has been specified\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-cli/app/app.ts","lineNumber":109,"sourceCode":"\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);\n\n\t\tif (type === ModelType.Note && pattern.indexOf('*') >= 0) {\n\t\t\t// Handle it as pattern\n\t\t\tif (!parent) throw new Error(_('No notebook selected.'));\n\t\t\treturn await Note.previews(parent.id, { titlePattern: pattern });\n\t\t} else {\n\t\t\t// Single item\n\t\t\tlet item = null;\n\t\t\tif (type === ModelType.Note) {\n\t\t\t\tif (!parent) throw new Error(_('No notebook has been specified.'));\n\t\t\t\titem = await (ItemClass as typeof Note).loadFolderNoteByField(parent.id, 'title', pattern);\n\t\t\t} else {\n\t\t\t\titem = await ItemClass.loadByTitle(pattern);\n\t\t\t}\n\t\t\tif (item) return [item];\n\n\t\t\titem = await ItemClass.load(pattern); // Load by id\n\t\t\tif (item) return [item];\n\n\t\t\tif (pattern.length >= 2) {\n\t\t\t\treturn await ItemClass.loadByPartialId(pattern);\n\t\t\t}\n\t\t}\n\n\t\treturn [];\n\t}\n\n\tpublic setupCommand(cmd: BaseCommand) {","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/app-cli/app/app.ts#L91-L127","documentation":"In App.loadItems, when looking up a single note by title (no wildcard), the query is scoped to a parent notebook via loadFolderNoteByField(parent.id, 'title', pattern). If no parent notebook is available (currentFolder() is null and no options.parent), it throws 'No notebook has been specified.'. The message is i18n-translated.","triggerScenarios":"Looking up a note by title while no notebook is current and no explicit parent is passed — e.g. running 'cat mynote' in a fresh session before 'use'.","commonSituations":"Same as the wildcard variant: no notebook selected, all notebooks deleted, or scripting without setting a parent.","solutions":["Select a notebook first: 'use <notebook>'.","Pass options.parent explicitly in code.","Create a notebook if none exist: 'mkbook <name>'.","Look up the note by id instead of title (id lookups do not require a parent)."],"exampleFix":"// before\n//   const note = await app().loadItem(ModelType.Note, 'shopping'); // throws\n// after\n//   const note = await app().loadItem(ModelType.Note, 'shopping', { parent: myFolder });","handlingStrategy":"validation","validationCode":"const parent = options?.parent ?? app().currentFolder();\nif (type === ModelType.Note && !parent) {\n  throw new Error('Specify a notebook before looking up a note by title.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await app().loadItem(ModelType.Note, title);\n} catch (e) {\n  if (/No notebook has been specified/.test(e.message)) {\n    await app().switchCurrentFolder(defaultFolderId);\n  }\n}","preventionTips":["Set a current notebook at the start of any note-by-title workflow.","Look up notes by id when no notebook context is available.","Pass options.parent in programmatic callers."],"tags":["cli","notebook","item-lookup","i18n"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}