siyuan-note/siyuan · error

no notebooks to update

Error message

no notebooks to update

What it means

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.

Solutions

  1. Open at least one notebook (`notebook open --id <id>` or via UI)
  2. Confirm the workspace contains notebooks (`notebook ls`)
  3. Initialize/create a notebook before running bulk updates

Example fix

// before
siyuan notebook icons update --icon "1f4d8"   # empty workspace
// after
siyuan notebook create --name "Notes"
siyuan notebook icons update --icon "1f4d8"
Defensive patterns

Strategy: validation

Validate before calling

[ -n "$(siyuan notebook ls)" ] || { echo "no open notebooks; open one first"; exit 1; }

Type guard

const hasTargets = (list) => Array.isArray(list) && list.length > 0;

Try / catch

try { run(updateCmd); } catch (e) { if (/no notebooks/.test(e.message)) openDefaultNotebook(); }

Prevention

When it happens

Trigger: Running the icon update when no notebooks are open/present in the workspace (e.g. all notebooks closed or the workspace is fresh).

Common situations: Operating on an empty or newly created workspace, or all notebooks closed so model state yields no targets.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/1ecab213e3861fd1. Report an issue: GitHub.

Appendix: 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 9f775e8a12)