{"record":{"id":"1ecab213e3861fd1","repo":"siyuan-note/siyuan","slug":"no-notebooks-to-update","errorCode":null,"errorMessage":"no notebooks to update","messagePattern":"no notebooks to update","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/cli/cmd/notebook.go","lineNumber":293,"sourceCode":"\t\t}\n\n\t\t// 目标范围：传 id 仅换该笔记本；不传则对全部笔记本各随机换一个。\n\t\ttargets := notebooks\n\t\tif id != \"\" {\n\t\t\tvar found *model.Box\n\t\t\tfor _, nb := range notebooks {\n\t\t\t\tif nb.ID == id {\n\t\t\t\t\tfound = nb\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif found == nil {\n\t\t\t\treturn fmt.Errorf(\"notebook not found: %s\", id)\n\t\t\t}\n\t\t\ttargets = []*model.Box{found}\n\t\t}\n\t\tif len(targets) == 0 {\n\t\t\treturn fmt.Errorf(\"no notebooks to update\")\n\t\t}\n\n\t\t// 先把拟定的新图标算好，便于 dry-run 预览与失败回滚。\n\t\ttype change struct {\n\t\t\tID      string `json:\"id\"`\n\t\t\tName    string `json:\"name\"`\n\t\t\tOldIcon string `json:\"oldIcon\"`\n\t\t\tNewIcon string `json:\"newIcon\"`\n\t\t}\n\t\tchanges := make([]change, 0, len(targets))\n\t\tfor _, nb := range targets {\n\t\t\tchanges = append(changes, change{ID: nb.ID, Name: nb.Name, OldIcon: nb.Icon, NewIcon: randomEmoji()})\n\t\t}\n\n\t\tif dryRun {\n\t\t\tfor _, c := range changes {\n\t\t\t\tfmt.Printf(\"[dry-run] Would set notebook %s (%s) icon %s -> %s\\n\", c.ID, c.Name, c.OldIcon, c.NewIcon)\n\t\t\t}","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/notebook.go#L275-L311","documentation":"Returned by the `notebook random-icon` subcommand when there are no notebooks to update. After resolving targets (either all notebooks or a single matched one), an empty target slice means nothing to randomize.","triggerScenarios":"model.ListNotebooks() returns an empty slice (no notebooks exist in the workspace) and --id was omitted, so targets == notebooks == [].","commonSituations":"Running against a fresh/empty workspace, a workspace whose notebooks are all in a closed/hidden state that ListNotebooks filters out, or pointing at the wrong data directory.","solutions":["Create a notebook first with `notebook create --name <name>`, then retry.","Verify the workspace path is the one that actually contains your notebooks.","Run `notebook list` to confirm the notebook inventory."],"exampleFix":"# before (empty workspace)\nsiyuan notebook random-icon\ngot: no notebooks to update\n# after\nsiyuan notebook create --name \"Inbox\"\nsiyuan notebook random-icon","handlingStrategy":"validation","validationCode":"# create at least one notebook before randomizing icons\nif [ \"$(siyuan notebook list --output json | jq 'length')\" -eq 0 ]; then\n  siyuan notebook create --name \"Inbox\"\nfi\nsiyuan notebook random-icon","typeGuard":"n/a (empty-state guard)","tryCatchPattern":"n/a (no side effect; the command aborts cleanly)","preventionTips":["On fresh workspaces, create a notebook before running icon commands.","Confirm you are pointed at the intended workspace/data directory."],"tags":["cli","notebook","validation","empty-state"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}