{"record":{"id":"b94aca6d6bc4fe5e","repo":"siyuan-note/siyuan","slug":"notebook-not-found-s","errorCode":null,"errorMessage":"notebook not found: %s","messagePattern":"notebook not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/notebook.go","lineNumber":242,"sourceCode":"\t\t}\n\t\tif icon == \"\" {\n\t\t\treturn fmt.Errorf(\"--icon is required\")\n\t\t}\n\n\t\t// 校验笔记本存在，避免对一个不存在的 id 静默写入图标。\n\t\texists := false\n\t\tnotebooks, err := model.ListNotebooks()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfor _, nb := range notebooks {\n\t\t\tif nb.ID == id {\n\t\t\t\texists = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !exists {\n\t\t\treturn fmt.Errorf(\"notebook not found: %s\", id)\n\t\t}\n\n\t\tif dryRun {\n\t\t\tfmt.Printf(\"[dry-run] Would set notebook %s icon to %s\\n\", id, icon)\n\t\t\treturn nil\n\t\t}\n\n\t\t// SetBoxIcon 内部对自定义图片名做 XSS 过滤。\n\t\tmodel.SetBoxIcon(id, icon)\n\n\t\tswitch outputFormat {\n\t\tcase \"json\":\n\t\t\tdata, _ := json.MarshalIndent(map[string]string{\"id\": id, \"icon\": icon}, \"\", \"  \")\n\t\t\tfmt.Println(string(data))\n\t\tdefault:\n\t\t\tfmt.Printf(\"%s\\t%s\\n\", id, icon)\n\t\t}\n\t\treturn nil","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/notebook.go#L224-L260","documentation":"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.","triggerScenarios":"Running `notebook set-icon --id <bad-id> --icon <icon>` where the id is misspelled, truncated, or refers to a removed notebook.","commonSituations":"Using a document id instead of a notebook id, a stale id after the notebook was deleted, or an id copied from another workspace.","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"],"exampleFix":"// before\nsiyuan notebook set-icon --id 20240101-wrong --icon \"1f4d8\"\n// after\nsiyuan notebook ls\nsiyuan notebook set-icon --id 20240101120000-abcdefg --icon \"1f4d8\"","handlingStrategy":"validation","validationCode":"siyuan notebook ls --format json | jq -e --arg id \"$NB_ID\" 'map(.id) | index($id) != null' || { echo \"notebook not found: $NB_ID\"; exit 1; }","typeGuard":"const exists = (id, notebooks) => notebooks.some(n => n.id === id);","tryCatchPattern":"try { run(`siyuan notebook set-icon --id ${id} --icon ${icon}`); } catch (e) { if (e.message.includes(\"not found\")) console.error(\"Bad notebook id:\", id); }","preventionTips":["Copy ids verbatim from `notebook ls`","Do not confuse document ids with notebook ids","Check the workspace is the intended one"],"tags":["cli","not-found","notebook"],"backgroundTag":"entity-not-found","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}