siyuan-note/siyuan · error
--icon is required
Error message
--icon is required
What it means
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.
Source
Thrown at kernel/cli/cmd/notebook.go:226
for _, b := range boxes {
fmt.Fprintf(w, "%s\t%s\t%v\t%d\n", b.ID, b.Name, b.Closed, b.Sort)
}
w.Flush()
}
// notebookSetIconCmd 设置笔记本图标。
// icon 取值格式:emoji hex 码点(如 "1f4ca")、emoji 字符、自定义图片路径、网络图片 URL 或动态图标 URL。
var notebookSetIconCmd = &cobra.Command{
Use: "set-icon --id <id> --icon <icon>",
Short: "Set a notebook icon",
RunE: func(cmd *cobra.Command, args []string) error {
id, _ := cmd.Flags().GetString("id")
icon, _ := cmd.Flags().GetString("icon")
if id == "" {
return fmt.Errorf("--id is required")
}
if icon == "" {
return fmt.Errorf("--icon is required")
}
// 校验笔记本存在,避免对一个不存在的 id 静默写入图标。
exists := false
notebooks, err := model.ListNotebooks()
if err != nil {
return err
}
for _, nb := range notebooks {
if nb.ID == id {
exists = true
break
}
}
if !exists {
return fmt.Errorf("notebook not found: %s", id)
}
View on GitHub (pinned to 251596fc0d)
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.
Example fix
# before siyuan notebook set-icon --id 202405121200-realid # after siyuan notebook set-icon --id 202405121200-realid --icon 1f4ca
Defensive patterns
Strategy: validation
Validate before calling
[ -n "$ICON" ] || { echo 'set-icon requires --icon'; exit 1; }
# icon may be hex codepoint, emoji char, image path, or URL
siyuan notebook set-icon --id "$NB_ID" --icon "$ICON" Type guard
n/a (CLI flag validation)
Try / catch
n/a
Prevention
- 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.
When it happens
Trigger: Running `notebook set-icon --id <id>` with no --icon, or `--icon ""`.
Common situations: Forgetting the icon flag, passing an unset shell variable, or not knowing the accepted icon formats.
Related errors
- --notebook is required
- --notebook is required
- --name is required
- --id is required
- path belongs to encrypted notebook [%s]: %s
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/8b56ce27c5fff8f2.
Report an issue: GitHub.