laurent22/joplin · error · Error
No notebook has been specified.
Error message
No notebook has been specified.
What it means
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.
Source
Thrown at packages/app-cli/app/app.ts:109
pattern = pattern ? pattern.toString() : '';
if (type === ModelType.Folder && (pattern === Folder.conflictFolderTitle() || pattern === Folder.conflictFolderId())) return [Folder.conflictFolder()];
if (!options) options = {};
const parent = options.parent ? options.parent : app().currentFolder();
const ItemClass = BaseItem.itemClass(type);
if (type === ModelType.Note && pattern.indexOf('*') >= 0) {
// Handle it as pattern
if (!parent) throw new Error(_('No notebook selected.'));
return await Note.previews(parent.id, { titlePattern: pattern });
} else {
// Single item
let item = null;
if (type === ModelType.Note) {
if (!parent) throw new Error(_('No notebook has been specified.'));
item = await (ItemClass as typeof Note).loadFolderNoteByField(parent.id, 'title', pattern);
} else {
item = await ItemClass.loadByTitle(pattern);
}
if (item) return [item];
item = await ItemClass.load(pattern); // Load by id
if (item) return [item];
if (pattern.length >= 2) {
return await ItemClass.loadByPartialId(pattern);
}
}
return [];
}
public setupCommand(cmd: BaseCommand) {View on GitHub (pinned to 2654b33620)
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).
Example fix
// before
// const note = await app().loadItem(ModelType.Note, 'shopping'); // throws
// after
// const note = await app().loadItem(ModelType.Note, 'shopping', { parent: myFolder }); Defensive patterns
Strategy: validation
Validate before calling
const parent = options?.parent ?? app().currentFolder();
if (type === ModelType.Note && !parent) {
throw new Error('Specify a notebook before looking up a note by title.');
} Try / catch
try {
await app().loadItem(ModelType.Note, title);
} catch (e) {
if (/No notebook has been specified/.test(e.message)) {
await app().switchCurrentFolder(defaultFolderId);
}
} Prevention
- 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.
When it happens
Trigger: 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'.
Common situations: Same as the wildcard variant: no notebook selected, all notebooks deleted, or scripting without setting a parent.
Related errors
- Cannot find "%s".
- More than one item match "%s". Please narrow down your query
- Cannot find "%s".
- No notebook selected.
- Cannot find "%s".
AI-assisted analysis of laurent22/joplin@2654b33620 (2026-08-12).
Data as JSON: /api/errors/c934299271da99cc.
Report an issue: GitHub.