{"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":"validation","errorClass":null,"httpStatus":null,"severity":"error","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/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/notebook.go#L275-L311","documentation":"Thrown by the random-icon update command when the resolved target set is empty: either the workspace has no notebooks at all (no --id given) or, after selecting a specific --id, targets was reduced but empty. It signals there is nothing to re-icon; create a notebook or pass a valid --id.","triggerScenarios":"Running the icon update when no notebooks are open/present in the workspace (e.g. all notebooks closed or the workspace is fresh).","commonSituations":"Operating on an empty or newly created workspace, or all notebooks closed so model state yields no targets.","solutions":["Open at least one notebook (`notebook open --id <id>` or via UI)","Confirm the workspace contains notebooks (`notebook ls`)","Initialize/create a notebook before running bulk updates"],"exampleFix":"// before\nsiyuan notebook icons update --icon \"1f4d8\"   # empty workspace\n// after\nsiyuan notebook create --name \"Notes\"\nsiyuan notebook icons update --icon \"1f4d8\"","handlingStrategy":"validation","validationCode":"[ -n \"$(siyuan notebook ls)\" ] || { echo \"no open notebooks; open one first\"; exit 1; }","typeGuard":"const hasTargets = (list) => Array.isArray(list) && list.length > 0;","tryCatchPattern":"try { run(updateCmd); } catch (e) { if (/no notebooks/.test(e.message)) openDefaultNotebook(); }","preventionTips":["Ensure at least one open notebook before bulk operations","Check workspace contents when bootstrapping automation","Create/open a notebook in setup scripts"],"tags":["cli","empty-state","notebook"],"backgroundTag":"empty-result-set","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"}