siyuan-note/siyuan · warning

no notebooks to update

Error message

no notebooks to update

What it means

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.

Source

Thrown at kernel/cli/cmd/notebook.go:293

		}

		// 目标范围:传 id 仅换该笔记本;不传则对全部笔记本各随机换一个。
		targets := notebooks
		if id != "" {
			var found *model.Box
			for _, nb := range notebooks {
				if nb.ID == id {
					found = nb
					break
				}
			}
			if found == nil {
				return fmt.Errorf("notebook not found: %s", id)
			}
			targets = []*model.Box{found}
		}
		if len(targets) == 0 {
			return fmt.Errorf("no notebooks to update")
		}

		// 先把拟定的新图标算好,便于 dry-run 预览与失败回滚。
		type change struct {
			ID      string `json:"id"`
			Name    string `json:"name"`
			OldIcon string `json:"oldIcon"`
			NewIcon string `json:"newIcon"`
		}
		changes := make([]change, 0, len(targets))
		for _, nb := range targets {
			changes = append(changes, change{ID: nb.ID, Name: nb.Name, OldIcon: nb.Icon, NewIcon: randomEmoji()})
		}

		if dryRun {
			for _, c := range changes {
				fmt.Printf("[dry-run] Would set notebook %s (%s) icon %s -> %s\n", c.ID, c.Name, c.OldIcon, c.NewIcon)
			}

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Create a notebook first with `notebook create --name <name>`, then retry.
  2. Verify the workspace path is the one that actually contains your notebooks.
  3. Run `notebook list` to confirm the notebook inventory.

Example fix

# before (empty workspace)
siyuan notebook random-icon
got: no notebooks to update
# after
siyuan notebook create --name "Inbox"
siyuan notebook random-icon
Defensive patterns

Strategy: validation

Validate before calling

# create at least one notebook before randomizing icons
if [ "$(siyuan notebook list --output json | jq 'length')" -eq 0 ]; then
  siyuan notebook create --name "Inbox"
fi
siyuan notebook random-icon

Type guard

n/a (empty-state guard)

Try / catch

n/a (no side effect; the command aborts cleanly)

Prevention

When it happens

Trigger: model.ListNotebooks() returns an empty slice (no notebooks exist in the workspace) and --id was omitted, so targets == notebooks == [].

Common situations: 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.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/1ecab213e3861fd1. Report an issue: GitHub.