{"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/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/notebook.go#L224-L260","documentation":"Returned by the `notebook set-icon` subcommand after it calls model.ListNotebooks and fails to find any notebook whose ID matches the provided --id. The lookup prevents silently writing an icon for a non-existent notebook.","triggerScenarios":"Passing a --id that does not match any nb.ID in the result of model.ListNotebooks(); the `exists` flag stays false and the handler returns this error before reaching SetBoxIcon.","commonSituations":"Stale or typo'd notebook ID, wrong workspace, or the notebook was removed/renamed in another session since the ID was obtained.","solutions":["Run `notebook list` and copy the exact ID, then retry.","Verify the kernel is pointed at the correct workspace/data directory.","If scripting, validate the ID exists before calling set-icon."],"exampleFix":"# before\nsiyuan notebook set-icon --id stale-id --icon 1f4ca\ngot: notebook not found: stale-id\n# after\nsiyuan notebook list  # confirm real id\nsiyuan notebook set-icon --id 202405121200-realid --icon 1f4ca","handlingStrategy":"validation","validationCode":"func notebookExists(id string) bool {\n    nbs, err := model.ListNotebooks()\n    if err != nil {\n        return false\n    }\n    for _, nb := range nbs {\n        if nb.ID == id {\n            return true\n        }\n    }\n    return false\n}\n\nif !notebookExists(id) {\n    return fmt.Errorf(\"will not set icon: notebook %s not found\", id)\n}","typeGuard":"n/a (Go; use the boolean helper above)","tryCatchPattern":"n/a (the CLI handler performs the lookup itself; callers should pre-check)","preventionTips":["Always obtain notebook IDs from a current `notebook list`.","When scripting icon changes across many notebooks, filter your ID list through ListNotebooks first."],"tags":["cli","notebook","validation","not-found"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}