{"record":{"id":"52a89088c2fce4c2","repo":"apache/cassandra","slug":"specifying-snapshot-name-together-with-older-tha-52a890","errorCode":null,"errorMessage":"Specifying snapshot name together with --older-than-timestamp flag is not allowed","messagePattern":"Specifying snapshot name together with --older-than-timestamp flag is not allowed","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/ClearSnapshot.java","lineNumber":76,"sourceCode":"    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            }\n            catch (DateTimeParseException ex)\n            {\n                throw new IllegalArgumentException(\"Parameter --older-than-timestamp has to be a valid instant in ISO format.\");\n            }\n\n        Long olderThanInSeconds = null;\n        if (olderThan != null)\n            // fail fast when it is not valid\n            olderThanInSeconds = new DurationSpec.LongSecondsBound(olderThan).toSeconds();\n\n        StringBuilder sb = new StringBuilder();\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/ClearSnapshot.java#L58-L94","documentation":"IllegalArgumentException from ClearSnapshot.execute: mutually exclusive options were supplied — a snapshot name together with --older-than-timestamp. Clearing is either by exact name or by timestamp cutoff, never both, so the command rejects the invocation before touching any snapshots.","triggerScenarios":"Running `nodetool clearsnapshot --snapshot snap1 --older-than-timestamp 2026-01-01T00:00:00Z`.","commonSituations":"Scripts combining point-in-time cleanup with a named snapshot; misunderstanding that the timestamp filters 'whether' the named snapshot is deleted.","solutions":["Check the snapshot's creation time via `nodetool listsnapshots` and delete by name only if it predates the cutoff","Use --all --older-than-timestamp <instant> for cutoff-based bulk deletion","Remove --older-than-timestamp to delete the named snapshot regardless of age"],"exampleFix":"// before\nnodetool clearsnapshot --snapshot snap1 --older-than-timestamp 2026-01-01T00:00:00Z\n// after\nnodetool clearsnapshot --snapshot snap1","handlingStrategy":"validation","validationCode":"if snapName and olderThanTimestamp: raise SystemExit(\"name-based deletion cannot use --older-than-timestamp\")","typeGuard":null,"tryCatchPattern":"try { clearSnapshot(); }\ncatch (IllegalArgumentException e) { /* adjust flags */ }","preventionTips":["Keep timestamp filtering with --all only","Use listsnapshots to check a named snapshot's age manually","Separate named-snapshot and bulk-cleanup code paths"],"tags":["nodetool","cli","snapshots","validation"],"backgroundTag":"mutually-exclusive-flags","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"}