siyuan-note/siyuan · error
--path is required
Error message
--path is required
What it means
Thrown by the `history get` subcommand when the `--path` flag is empty. The path identifies a specific historical file entry inside the history store; it is passed straight to `model.GetDocHistoryContent`. Without a path the model cannot locate a history snapshot to read.
Source
Thrown at kernel/cli/cmd/history.go:95
for _, ts := range timestamps {
items := model.FullTextSearchHistoryItems(ts, query, box, op, typ)
fmt.Printf("[%s] %d item(s)\n", ts, len(items))
for _, item := range items {
fmt.Printf(" %-8s %s %s\n", item.Op, truncate(item.Title, 60), item.Path)
}
}
fmt.Printf("\nPage %d/%d, %d total\n", page, pageCount, totalCount)
}
return nil
}
var historyGetCmd = &cobra.Command{
Use: "get --path <path>",
Short: "Get historical file content",
RunE: func(cmd *cobra.Command, args []string) error {
historyPath, _ := cmd.Flags().GetString("path")
if historyPath == "" {
return fmt.Errorf("--path is required")
}
_, _, content, _, err := model.GetDocHistoryContent(historyPath, "", false)
if err != nil {
return err
}
fmt.Print(content)
return nil
},
}
var historyRollbackCmd = &cobra.Command{
Use: "rollback --path <path>",
Short: "Rollback a document to historical version",
RunE: func(cmd *cobra.Command, args []string) error {
historyPath, _ := cmd.Flags().GetString("path")
if historyPath == "" {
return fmt.Errorf("--path is required")View on GitHub (pinned to 251596fc0d)
Solutions
- Run `siyuan history list` first to obtain the history entry path
- Pass it: `siyuan history get --path <historyPath>`
Example fix
// before siyuan history get // after siyuan history get --path 2024-01/history/20240101120000-abc/edit/20240101130000-abc.sy
Defensive patterns
Strategy: validation
Validate before calling
if historyPath == "" {
// list first, then select
out, _ := cmd.Output("siyuan", "history", "list")
_ = out
} Prevention
- Run `history list` to obtain valid paths before `history get`
- Note the path points at a history entry, not a doc ID
- Copy the exact path from `history list` output to avoid typos
When it happens
Trigger: Running `siyuan history get` with no `--path`. The RunE reads the flag and returns the error before calling `model.GetDocHistoryContent(historyPath, "", false)`.
Common situations: Forgetting that the history path (not a doc ID) is required; not knowing the history path format; confusing this with `history list` which needs no path.
Related errors
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/adc220f970e3c93b.
Report an issue: GitHub.