{"record":{"id":"6512cfdca008c088","repo":"apache/cassandra","slug":"specifying-snapshot-name-together-with-older-tha","errorCode":null,"errorMessage":"Specifying snapshot name together with --older-than flag is not allowed","messagePattern":"Specifying snapshot name together with --older-than flag is not allowed","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/ClearSnapshot.java","lineNumber":73,"sourceCode":"\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            }\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();","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/ClearSnapshot.java#L55-L91","documentation":"When using the --older-than duration filter, clearsnapshot does not allow naming a specific snapshot, since age filtering applies to sets of snapshots. Combining --snapshot with --older-than throws this IllegalArgumentException.","triggerScenarios":"Running `nodetool clearsnapshot --snapshot snap1 --older-than 7d`.","commonSituations":"Users wanting to delete a named snapshot only if it is older than some age — not supported; or scripts merging two cleanup code paths.","solutions":["Implement the age check externally: use `nodetool listsnapshots` to inspect snapshot timestamps, then delete by name if old enough","Drop the snapshot name and use --all --older-than <duration> for age-based bulk cleanup","Drop --older-than and delete the named snapshot unconditionally"],"exampleFix":"// before\nnodetool clearsnapshot --snapshot snap1 --older-than 7d\n// after\nnodetool clearsnapshot --all --older-than 7d","handlingStrategy":"validation","validationCode":"if snapName and olderThan: raise SystemExit(\"name-based deletion cannot use --older-than\")","typeGuard":null,"tryCatchPattern":"try { clearSnapshot(); }\ncatch (IllegalArgumentException e) { /* adjust flags */ }","preventionTips":["For age-based deletion use --all --older-than","For named deletion omit age flags","Check listsnapshots output for snapshot ages"],"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"}