{"record":{"id":"7031f20f1ed91cee","repo":"siyuan-note/siyuan","slug":"id-is-required-7031f2","errorCode":null,"errorMessage":"--id is required","messagePattern":"--id is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/repo.go","lineNumber":157,"sourceCode":"\t\t\tfmt.Printf(\"[dry-run] Would remove snapshot tag \\\"%s\\\"\\n\", name)\n\t\t\treturn nil\n\t\t}\n\n\t\tif err := model.RemoveTagSnapshot(name); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfmt.Println(\"ok\")\n\t\treturn nil\n\t},\n}\n\nvar repoCheckoutCmd = &cobra.Command{\n\tUse:   \"checkout --id <id>\",\n\tShort: \"Checkout (rollback to) a snapshot\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tid, _ := cmd.Flags().GetString(\"id\")\n\t\tif id == \"\" {\n\t\t\treturn fmt.Errorf(\"--id is required\")\n\t\t}\n\n\t\tif dryRun {\n\t\t\tfmt.Printf(\"[dry-run] Would rollback workspace to snapshot %s\\n\", id)\n\t\t\treturn nil\n\t\t}\n\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{","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/repo.go#L139-L175","documentation":"The `siyuan repo checkout` command rolls the workspace back to a snapshot and requires `--id` (snapshot ID). The RunE handler returns this error when the flag is empty, before the dry-run check or rollback executes.","triggerScenarios":"Running `siyuan repo checkout` with no `--id` flag or an empty value.","commonSituations":"Copy-pasting the command without substituting the snapshot ID; a snapshot lookup step upstream returned empty; confusing checkout (needs a snapshot ID) with file rollback commands.","solutions":["Re-run with: `siyuan repo checkout --id <snapshotID>`","List snapshots to obtain a valid ID first","Check upstream scripts for empty-variable expansion before invoking"],"exampleFix":"// before\nsiyuan repo checkout\n// after\nsiyuan repo checkout --id 20240101120000-abcdefg","handlingStrategy":"validation","validationCode":"[ -n \"$SNAP_ID\" ] || { echo \"repo checkout: missing --id\" >&2; exit 2; }\nsiyuan repo checkout --id \"$SNAP_ID\"","typeGuard":"function requireFlag(v) { if (typeof v !== 'string' || v.trim() === '') throw new Error('--id is required'); return v; }","tryCatchPattern":"siyuan repo checkout --id \"$SNAP_ID\" || { echo 'checkout requires a snapshot ID via --id'; }","preventionTips":["List snapshots first and capture a real ID before checkout","Guard rollback scripts so an empty ID aborts instead of reaching the CLI","Prefer --dry-run when rehearsing checkout commands"],"tags":["cli","missing-flag","snapshot"],"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"}