{"record":{"id":"fd52379a82f10220","repo":"siyuan-note/siyuan","slug":"left-and-right-are-required","errorCode":null,"errorMessage":"--left and --right are required","messagePattern":"--left and --right are required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/repo.go","lineNumber":182,"sourceCode":"\n\t\tif err := model.CheckoutRepoDirect(id); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmodel.AppendPushReloadFiletreeEntry()\n\t\tmodel.AppendPushReloadUIEntry()\n\t\tfmt.Println(\"ok\")\n\t\treturn nil\n\t},\n}\n\nvar repoDiffCmd = &cobra.Command{\n\tUse:   \"diff --left <id> --right <id>\",\n\tShort: \"Diff two snapshots\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tleft, _ := cmd.Flags().GetString(\"left\")\n\t\tright, _ := cmd.Flags().GetString(\"right\")\n\t\tif left == \"\" || right == \"\" {\n\t\t\treturn fmt.Errorf(\"--left and --right are required\")\n\t\t}\n\t\tdiff, err := model.DiffRepoSnapshots(left, right)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdata, _ := json.MarshalIndent(diff, \"\", \"  \")\n\t\tfmt.Println(string(data))\n\t\treturn nil\n\t},\n}\n\nvar repoSearchCmd = &cobra.Command{\n\tUse:   \"search <keyword>\",\n\tShort: \"Search files in snapshots\",\n\tArgs:  cobra.MinimumNArgs(1),\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tkeyword := args[0]\n\t\tpage, _ := cmd.Flags().GetInt(\"page\")","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/repo.go#L164-L200","documentation":"The `siyuan repo diff` command compares two repo snapshots and requires both `--left` and `--right` snapshot IDs. The RunE handler returns this error when either is empty, before calling model.DiffRepoSnapshots.","triggerScenarios":"Running `siyuan repo diff` with only one of `--left`/`--right`, or neither; e.g. `siyuan repo diff --left <id>`.","commonSituations":"Assuming HEAD/current-workspace defaults exist (they do not; both endpoints are mandatory); scripts building the diff line where one endpoint variable is empty.","solutions":["Re-run with both flags: `siyuan repo diff --left <id1> --right <id2>`","Obtain both snapshot IDs (e.g. from snapshot list output) before diffing","Check that neither ID variable is empty in generated command lines"],"exampleFix":"// before\nsiyuan repo diff --right 20240101120000-xyz\n// after\nsiyuan repo diff --left 20240101120000-abc --right 20240101120000-xyz","handlingStrategy":"validation","validationCode":"[ -n \"$LEFT\" ] && [ -n \"$RIGHT\" ] || { echo \"repo diff: need --left and --right\" >&2; exit 2; }\nsiyuan repo diff --left \"$LEFT\" --right \"$RIGHT\"","typeGuard":"function requireBoth(a, b) { if (!a || !b) throw new Error('--left and --right are required'); }","tryCatchPattern":"siyuan repo diff --left \"$LEFT\" --right \"$RIGHT\" || { echo 'diff needs two snapshot IDs'; }","preventionTips":["There is no default endpoint (no HEAD-like implicit snapshot); supply both IDs","Build diff command lines programmatically and assert both variables are non-empty","Quote both flag values in shell scripts"],"tags":["cli","missing-flag","diff"],"backgroundTag":"missing-required-flag","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}