siyuan-note/siyuan · error
--id is required
Error message
--id is required
What it means
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.
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
Example fix
// before siyuan repo checkout // after siyuan repo checkout --id 20240101120000-abcdefg
Defensive patterns
Strategy: validation
Validate before calling
[ -n "$SNAP_ID" ] || { echo "repo checkout: missing --id" >&2; exit 2; }
siyuan repo checkout --id "$SNAP_ID" Type guard
function requireFlag(v) { if (typeof v !== 'string' || v.trim() === '') throw new Error('--id is required'); return v; } Try / catch
siyuan repo checkout --id "$SNAP_ID" || { echo 'checkout requires a snapshot ID via --id'; } Prevention
- 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
When it happens
Trigger: Running `siyuan repo checkout` with no `--id` flag or an empty value.
Common situations: 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.
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
- --id and --name are required
- --name 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/7031f20f1ed91cee.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/cli/cmd/repo.go:157
fmt.Printf("[dry-run] Would remove snapshot tag \"%s\"\n", name)
return nil
}
if err := model.RemoveTagSnapshot(name); err != nil {
return err
}
fmt.Println("ok")
return nil
},
}
var repoCheckoutCmd = &cobra.Command{
Use: "checkout --id <id>",
Short: "Checkout (rollback to) a snapshot",
RunE: func(cmd *cobra.Command, args []string) error {
id, _ := cmd.Flags().GetString("id")
if id == "" {
return fmt.Errorf("--id is required")
}
if dryRun {
fmt.Printf("[dry-run] Would rollback workspace to snapshot %s\n", id)
return nil
}
if err := model.CheckoutRepoDirect(id); err != nil {
return err
}
model.AppendPushReloadFiletreeEntry()
model.AppendPushReloadUIEntry()
fmt.Println("ok")
return nil
},
}
var repoDiffCmd = &cobra.Command{View on GitHub (pinned to 9f775e8a12)