{"record":{"id":"8b56ce27c5fff8f2","repo":"siyuan-note/siyuan","slug":"icon-is-required","errorCode":null,"errorMessage":"--icon is required","messagePattern":"--icon is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/notebook.go","lineNumber":226,"sourceCode":"\tfor _, b := range boxes {\n\t\tfmt.Fprintf(w, \"%s\\t%s\\t%v\\t%d\\n\", b.ID, b.Name, b.Closed, b.Sort)\n\t}\n\tw.Flush()\n}\n\n// notebookSetIconCmd 设置笔记本图标。\n// icon 取值格式：emoji hex 码点（如 \"1f4ca\"）、emoji 字符、自定义图片路径、网络图片 URL 或动态图标 URL。\nvar notebookSetIconCmd = &cobra.Command{\n\tUse:   \"set-icon --id <id> --icon <icon>\",\n\tShort: \"Set a notebook icon\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tid, _ := cmd.Flags().GetString(\"id\")\n\t\ticon, _ := cmd.Flags().GetString(\"icon\")\n\t\tif id == \"\" {\n\t\t\treturn fmt.Errorf(\"--id is required\")\n\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","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/notebook.go#L208-L244","documentation":"Returned by the `notebook set-icon` subcommand when --icon is empty (after --id passed). The icon value (emoji hex codepoint, emoji char, custom image path, or URL) is required to set it.","triggerScenarios":"Running `notebook set-icon --id <id>` with no --icon, or `--icon \"\"`.","commonSituations":"Forgetting the icon flag, passing an unset shell variable, or not knowing the accepted icon formats.","solutions":["Provide --icon as an emoji hex codepoint (e.g. 1f4ca), an emoji character, a custom image path, or an image URL.","Run with --dry-run first to validate the intended change."],"exampleFix":"# before\nsiyuan notebook set-icon --id 202405121200-realid\n# after\nsiyuan notebook set-icon --id 202405121200-realid --icon 1f4ca","handlingStrategy":"validation","validationCode":"[ -n \"$ICON\" ] || { echo 'set-icon requires --icon'; exit 1; }\n# icon may be hex codepoint, emoji char, image path, or URL\nsiyuan notebook set-icon --id \"$NB_ID\" --icon \"$ICON\"","typeGuard":"n/a (CLI flag validation)","tryCatchPattern":"n/a","preventionTips":["Know the accepted --icon formats: emoji hex codepoint, emoji char, local image path, or image URL.","Use --dry-run to preview the icon change before it is written."],"tags":["cli","notebook","validation","missing-argument"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}