siyuan-note/siyuan · error
--id is required
Error message
--id is required
What it means
Returned by the `notebook remove` subcommand when the --id flag is empty. The RunE handler reads the flag and aborts before touching any model state, because removal requires a target identifier.
Source
Thrown at kernel/cli/cmd/notebook.go:106
}
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
}
if err := model.RemoveBox(id); err != nil {
return err
}
model.AppendPushReloadFiletreeEntry()
fmt.Println(id)
return nil
},
}
var notebookRenameCmd = &cobra.Command{
Use: "rename --id <id> --name <name>",View on GitHub (pinned to 251596fc0d)
Solutions
- Pass an explicit --id with a valid notebook ID: `notebook remove --id <id>`.
- If scripting, ensure the ID variable is non-empty before invoking the command.
- Run `notebook list` first to obtain a valid ID.
Example fix
# before siyuan notebook remove # after siyuan notebook remove --id 202405121200-realid
Defensive patterns
Strategy: validation
Validate before calling
# shell: assert before invoking if [ -z "$NB_ID" ]; then echo "NB_ID is empty"; exit 1; fi siyuan notebook remove --id "$NB_ID"
Type guard
n/a (CLI flag validation)
Try / catch
n/a (command aborts before any side effect; no partial state to recover)
Prevention
- Treat required flags as build inputs: validate them in your wrapper script before calling the CLI.
- Use `notebook list` to source valid IDs programmatically.
When it happens
Trigger: Invoking `notebook remove` with no --id flag, or with `--id ""` (empty string). cmd.Flags().GetString("id") returns "".
Common situations: Typing the command without arguments expecting a positional ID, assuming a default/selected notebook, or a wrapper script that fails to substitute the ID variable.
Related errors
- --notebook is required
- --notebook is required
- --name is required
- --icon 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/cdc7d1796e7b3a1a.
Report an issue: GitHub.