siyuan-note/siyuan · error

notebook [%s] not found

Error message

notebook [%s] not found

What it means

Thrown by formatNotebookWriteError when a notebook-mutating CLI command (create/open/remove/rename) receives model.ErrBoxNotFound from the kernel. The helper translates the low-level model error into a user-facing message naming the offending box ID. It exists so CLI users get an actionable message instead of an opaque sentinel error.

Source

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

		id, err := model.CreateBox(name)
		if err != nil {
			return err
		}
		if _, err = model.Mount(id); err != nil {
			return fmt.Errorf("notebook [%s] was created but could not be opened: %w", id, err)
		}
		model.AppendPushReloadFiletreeEntry()
		fmt.Println(id)
		return nil
	},
}

func formatNotebookWriteError(boxID string, err error) error {
	if errors.Is(err, model.ErrBoxClosed) {
		return fmt.Errorf("notebook [%s] is closed; run `notebook open --id %s` first", boxID, boxID)
	}
	if errors.Is(err, model.ErrBoxNotFound) {
		return fmt.Errorf("notebook [%s] not found", boxID)
	}
	return err
}

var notebookRemoveCmd = &cobra.Command{
	Use:   "remove --id <id>",
	Short: "Remove a notebook",
	RunE: func(cmd *cobra.Command, args []string) error {
		id, _ := cmd.Flags().GetString("id")
		if id == "" {
			return fmt.Errorf("--id is required")
		}

		if dryRun {
			fmt.Printf("[dry-run] Would remove notebook %s\n", id)
			return nil
		}

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Run `notebook list` to confirm the current valid notebook IDs, then retry with a correct --id value.
  2. Verify the workspace path the kernel is using (the --workspace flag / working dir) matches where the notebook was created.
  3. Check that the notebook is not on a different SiYuan instance or data directory.

Example fix

# before
siyuan notebook remove --id 202301010000-abc
got: notebook [202301010000-abc] not found
# after
siyuan notebook list
# pick a real id, then:
siyuan notebook remove --id 202405121200-realid
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate the notebook exists before calling a mutating model function.
func notebookExists(id string) bool {
    notebooks, err := model.ListNotebooks()
    if err != nil {
        return false
    }
    for _, nb := range notebooks {
        if nb.ID == id {
            return true
        }
    }
    return false
}

// before calling a write op:
if !notebookExists(boxID) {
    return fmt.Errorf("refusing to operate: notebook [%s] not found", boxID)
}

Type guard

n/a (Go; guard via boolean helper above)

Try / catch

err := model.RemoveBox(boxID)
if err != nil {
    if errors.Is(err, model.ErrBoxNotFound) {
        // surface a user-friendly message, optionally offer `notebook list`
        return fmt.Errorf("notebook [%s] not found; run `notebook list`", boxID)
    }
    return err
}

Prevention

When it happens

Trigger: A cobra subcommand in notebook.go calls a model.*Box function with a boxID that does not correspond to any mounted or known notebook, and the returned error is wrapped via formatNotebookWriteError(boxID, err). errors.Is(err, model.ErrBoxNotFound) is true.

Common situations: Passing a stale notebook ID copied from an old workspace, typos in --id, running the command against a different workspace/data dir than where the notebook lives, or referencing a notebook that was removed in another session.

Related errors


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