siyuan-note/siyuan · error
--old is required
Error message
--old is required
What it means
The `bookmark rename` command requires both --old (current label) and --new (new label). This error fires when --old is missing or empty (kernel/cli/cmd/bookmark.go:101), before model.RenameBookmark runs.
Solutions
- Provide both flags: bookmark rename --old "OldLabel" --new "NewLabel"
- List bookmarks first to confirm the exact current label used as --old
- In scripts, validate both variables are non-empty before invoking the command
Example fix
// before siyuan bookmark rename --new "Important" // after siyuan bookmark rename --old "TODO" --new "Important"
Defensive patterns
Strategy: validation
Validate before calling
if [ -z "$OLD" ] || [ -z "$NEW" ]; then echo "both --old and --new are required" >&2; exit 1; fi siyuan bookmark rename --old "$OLD" --new "$NEW"
Prevention
- Always pass both --old and --new together
- Source --old from a fresh bookmark list, not memory
- Validate variables in bulk-rename scripts before the loop starts
When it happens
Trigger: Running `bookmark rename --new "New"` without --old, or with `--old ""`; misspelling the flag so the empty default is read.
Common situations: Renaming bookmarks in bulk scripts where the old-label variable is unset; only partially updating a command line after copying the rename example; confusing this rename with attribute/attribute-view rename commands that use different flags.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
- --new is required
- --label is required
- --av and --ids are required
- --av, --key, --item and --value are required
- --block is required for non-detached rows
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/967cd4802ae2e1e8.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/cli/cmd/bookmark.go:101
return nil
}
if err := model.RemoveBookmark(label); err != nil {
return err
}
model.AppendPushReloadFiletreeEntry()
return nil
},
}
var bookmarkRenameCmd = &cobra.Command{
Use: "rename --old <old> --new <new>",
Short: "Rename a bookmark",
RunE: func(cmd *cobra.Command, args []string) error {
oldLabel, _ := cmd.Flags().GetString("old")
newLabel, _ := cmd.Flags().GetString("new")
if oldLabel == "" {
return fmt.Errorf("--old is required")
}
if newLabel == "" {
return fmt.Errorf("--new is required")
}
if dryRun {
fmt.Printf("[dry-run] Would rename bookmark \"%s\" to \"%s\"\n", oldLabel, newLabel)
return nil
}
if err := model.RenameBookmark(oldLabel, newLabel); err != nil {
return err
}
model.AppendPushReloadFiletreeEntry()
return nil
},
}
View on GitHub (pinned to 9f775e8a12)