{"record":{"id":"450a9e0f0f5d56d3","repo":"apache/cassandra","slug":"specify-snapshot-name-or-all","errorCode":null,"errorMessage":"Specify snapshot name or --all","messagePattern":"Specify snapshot name or --all","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/ClearSnapshot.java","lineNumber":64,"sourceCode":"\n    @Option(paramLabel = \"snapshot_name\", names = \"-t\", description = \"Remove the snapshot with a given name\")\n    private String snapshotName = EMPTY;\n\n    @Option(paramLabel = \"clear_all_snapshots\", names = \"--all\", description = \"Removes all snapshots\")\n    private boolean clearAllSnapshots = false;\n\n    @Option(paramLabel = \"older_than\", names = \"--older-than\", description = \"Clear snapshots older than specified time period.\")\n    private String olderThan;\n\n    @Option(paramLabel = \"older_than_timestamp\", names = \"--older-than-timestamp\",\n            description = \"Clear snapshots older than specified timestamp. It has to be a string in ISO format, for example '2022-12-03T10:15:30Z'\")\n    private String olderThanTimestamp;\n\n    @Override\n    public void execute(NodeProbe probe)\n    {\n        if (snapshotName.isEmpty() && !clearAllSnapshots)\n            throw new IllegalArgumentException(\"Specify snapshot name or --all\");\n\n        if (!snapshotName.isEmpty() && clearAllSnapshots)\n            throw new IllegalArgumentException(\"Specify only one of snapshot name or --all\");\n\n        if (olderThan != null && olderThanTimestamp != null)\n            throw new IllegalArgumentException(\"Specify only one of --older-than or --older-than-timestamp\");\n\n        if (!snapshotName.isEmpty() && olderThan != null)\n            throw new IllegalArgumentException(\"Specifying snapshot name together with --older-than flag is not allowed\");\n\n        if (!snapshotName.isEmpty() && olderThanTimestamp != null)\n            throw new IllegalArgumentException(\"Specifying snapshot name together with --older-than-timestamp flag is not allowed\");\n\n        if (olderThanTimestamp != null)\n            try\n            {\n                Instant.parse(olderThanTimestamp);\n            }","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/ClearSnapshot.java#L46-L82","documentation":"`nodetool clearsnapshot` requires identifying what to clear: either a specific --snapshot name or the --all flag. Calling it with neither throws this IllegalArgumentException as argument validation before contacting the node.","triggerScenarios":"Running bare `nodetool clearsnapshot` with no --snapshot/-n and no --all flag.","commonSituations":"Scripted snapshot cleanup that forgot the flag, users assuming default behavior clears snapshots, version upgrades where flag defaults changed.","solutions":["Pass a snapshot name: `nodetool clearsnapshot --snapshot <name>`","Use `nodetool clearsnapshot --all` to remove all snapshots (after confirming intent)","List existing snapshots with `nodetool listsnapshots` first to pick the right name"],"exampleFix":"// before\nnodetool clearsnapshot\n// after\nnodetool clearsnapshot --all","handlingStrategy":"validation","validationCode":"if [ -z \"$SNAP\" ] && [ -z \"$ALL\" ]; then echo \"need --snapshot or --all\"; exit 1; fi","typeGuard":null,"tryCatchPattern":"try { clearSnapshot(); }\ncatch (IllegalArgumentException e) { System.err.println(e.getMessage()); }","preventionTips":["Always pass --snapshot <name> or --all explicitly","Run nodetool listsnapshots before deleting","Never call clearsnapshot with no arguments in scripts"],"tags":["nodetool","cli","snapshots","validation"],"backgroundTag":"missing-required-flag","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}