{"record":{"id":"3df0d868f0b8bd59","repo":"k3s-io/k3s","slug":"no-snapshots-given-for-removal","errorCode":null,"errorMessage":"no snapshots given for removal","messagePattern":"no snapshots given for removal","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cli/etcdsnapshot/etcd_snapshot.go","lineNumber":158,"sourceCode":"\n\tfor _, name := range resp.Created {\n\t\tlogrus.Infof(\"Snapshot %s saved.\", name)\n\t}\n\n\treturn nil\n}\n\nfunc Delete(app *cli.Context) error {\n\tif err := cmds.InitLogging(); err != nil {\n\t\treturn err\n\t}\n\treturn deleteSnapshot(app, &cmds.ServerConfig)\n}\n\nfunc deleteSnapshot(app *cli.Context, cfg *cmds.Server) error {\n\tsnapshots := app.Args()\n\tif snapshots.Len() == 0 {\n\t\treturn errors.New(\"no snapshots given for removal\")\n\t}\n\n\tsr, info, err := commandSetup(app, cfg)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tsr.Operation = etcd.SnapshotOperationDelete\n\tsr.Name = snapshots.Slice()\n\n\tb, err := json.Marshal(sr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tr, err := info.Post(\"/db/snapshot\", b, clientaccess.WithTimeout(timeout))\n\tif err != nil {\n\t\treturn wrapServerError(err)\n\t}","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/k3s-io/k3s/blob/6ba341e396edc16b8dcae978a7c5e3ac7ee5606e/pkg/cli/etcdsnapshot/etcd_snapshot.go#L140-L176","documentation":"The `k3s etcd-snapshot delete` subcommand takes snapshot names as positional arguments. deleteSnapshot checks app.Args(); with zero arguments there is nothing to address the delete operation to, so it fails before contacting etcd. The CLI has no implicit delete-all, by design, to prevent accidental snapshot loss.","triggerScenarios":"Running `k3s etcd-snapshot delete` with no positional names; passing names as a flag (e.g. --name) instead of positional args so Args() stays empty.","commonSituations":"Scripts ported from other etcd tooling; users expecting `delete` with --prune semantics to need no target; shell quoting that expands an empty variable into no arguments.","solutions":["Pass one or more snapshot names positionally: k3s etcd-snapshot delete on-demand-12345","List available names first with k3s etcd-snapshot list to copy the exact name","To reduce count by policy, use retention/prune options on the server rather than a bare delete"],"exampleFix":"# before\nk3s etcd-snapshot delete  # -> no snapshots given for removal\n\n# after\nk3s etcd-snapshot list\nk3s etcd-snapshot delete etcd-snapshot-1699999999 on-demand-abc123","handlingStrategy":"validation","validationCode":"if app.Args().Len() == 0 {\n    return errors.New(\"etcd-snapshot delete requires one or more snapshot names; run `k3s etcd-snapshot list` first\")\n}","typeGuard":"func hasPositionalArgs(args []string) bool { return len(args) > 0 }","tryCatchPattern":null,"preventionTips":["Wrap delete calls: always `k3s etcd-snapshot list` then pass explicit names","Guard scripts: fail if the names array is empty instead of calling delete","Use shellcheck to catch `k3s etcd-snapshot delete $MAYBE_EMPTY` patterns"],"tags":["etcd","snapshot","cli","validation","backup"],"backgroundTag":null,"analyzedSha":"6ba341e396edc16b8dcae978a7c5e3ac7ee5606e","analyzedAt":"2026-08-15T16:27:54.286Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}