siyuan-note/siyuan · error
--left and --right are required
Error message
--left and --right are required
What it means
Returned by the `repo diff` subcommand when either --left or --right (snapshot IDs) is empty. Diffing two snapshots requires both endpoints; the combined `left == "" || right == ""` check fires before model.DiffRepoSnapshots.
Source
Thrown at kernel/cli/cmd/repo.go:176
return nil
}
model.CheckoutRepoDirect(id)
model.AppendPushReloadFiletreeEntry()
model.AppendPushReloadUIEntry()
fmt.Println("ok")
return nil
},
}
var repoDiffCmd = &cobra.Command{
Use: "diff --left <id> --right <id>",
Short: "Diff two snapshots",
RunE: func(cmd *cobra.Command, args []string) error {
left, _ := cmd.Flags().GetString("left")
right, _ := cmd.Flags().GetString("right")
if left == "" || right == "" {
return fmt.Errorf("--left and --right are required")
}
diff, err := model.DiffRepoSnapshots(left, right)
if err != nil {
return err
}
data, _ := json.MarshalIndent(diff, "", " ")
fmt.Println(string(data))
return nil
},
}
var repoSearchCmd = &cobra.Command{
Use: "search <keyword>",
Short: "Search files in snapshots",
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
keyword := args[0]
page, _ := cmd.Flags().GetInt("page")View on GitHub (pinned to 251596fc0d)
Solutions
- Provide both flags: `repo diff --left <id-a> --right <id-b>`.
- List snapshots to obtain both valid IDs.
Example fix
# before siyuan repo diff --left 20240601-abc got: --left and --right are required # after siyuan repo diff --left 20240601-abc --right 20240602-def
Defensive patterns
Strategy: validation
Validate before calling
[ -n "$LEFT" ] && [ -n "$RIGHT" ] || { echo 'repo diff requires --left and --right'; exit 1; }
siyuan repo diff --left "$LEFT" --right "$RIGHT" Type guard
n/a (CLI flag validation)
Try / catch
n/a
Prevention
- Diff needs two distinct snapshot IDs; supply both as flags (not positional).
- Source both IDs from a snapshot listing to ensure they exist.
When it happens
Trigger: Running `repo diff` with one or both of --left / --right missing or empty.
Common situations: Passing only one snapshot ID, mixing up positional vs flag usage, or a script that left one variable blank.
Related errors
- --id and --name are required
- --name is required
- --id is required
- --pattern is required
- --path is required
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/fd52379a82f10220.
Report an issue: GitHub.