siyuan-note/siyuan · error
notebook not found
Error message
notebook not found: %s
What it means
After reading the flag values, `set-icon` lists all notebooks via model.ListNotebooks and scans for a matching ID. If no notebook with the given ID exists, the command aborts rather than silently writing an icon for a nonexistent notebook.
Solutions
- Run `siyuan notebook ls` and copy the exact ID
- Confirm you are operating on the correct workspace
- Retry with `--dry-run` to validate the id without writing
Example fix
// before siyuan notebook set-icon --id 20240101-wrong --icon "1f4d8" // after siyuan notebook ls siyuan notebook set-icon --id 20240101120000-abcdefg --icon "1f4d8"
Defensive patterns
Strategy: validation
Validate before calling
siyuan notebook ls --format json | jq -e --arg id "$NB_ID" 'map(.id) | index($id) != null' || { echo "notebook not found: $NB_ID"; exit 1; } Type guard
const exists = (id, notebooks) => notebooks.some(n => n.id === id);
Try / catch
try { run(`siyuan notebook set-icon --id ${id} --icon ${icon}`); } catch (e) { if (e.message.includes("not found")) console.error("Bad notebook id:", id); } Prevention
- Copy ids verbatim from `notebook ls`
- Do not confuse document ids with notebook ids
- Check the workspace is the intended one
When it happens
Trigger: Running `notebook set-icon --id <bad-id> --icon <icon>` where the id is misspelled, truncated, or refers to a removed notebook.
Common situations: Using a document id instead of a notebook id, a stale id after the notebook was deleted, or an id copied from another workspace.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- 0
- block not found
- block [ ] is not a sortable document
- CLI does not support encrypted notebook
- Conf.Language(0)
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/b94aca6d6bc4fe5e.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/cli/cmd/notebook.go:242
}
if icon == "" {
return fmt.Errorf("--icon is required")
}
// 校验笔记本存在,避免对一个不存在的 id 静默写入图标。
exists := false
notebooks, err := model.ListNotebooks()
if err != nil {
return err
}
for _, nb := range notebooks {
if nb.ID == id {
exists = true
break
}
}
if !exists {
return fmt.Errorf("notebook not found: %s", id)
}
if dryRun {
fmt.Printf("[dry-run] Would set notebook %s icon to %s\n", id, icon)
return nil
}
// SetBoxIcon 内部对自定义图片名做 XSS 过滤。
model.SetBoxIcon(id, icon)
switch outputFormat {
case "json":
data, _ := json.MarshalIndent(map[string]string{"id": id, "icon": icon}, "", " ")
fmt.Println(string(data))
default:
fmt.Printf("%s\t%s\n", id, icon)
}
return nilView on GitHub (pinned to 9f775e8a12)