{"record":{"id":"affbf6e2313ef011","repo":"apache/cassandra","slug":"specify-only-one-of-older-than-or-older-than-t","errorCode":null,"errorMessage":"Specify only one of --older-than or --older-than-timestamp","messagePattern":"Specify only one of --older-than or --older-than-timestamp","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/ClearSnapshot.java","lineNumber":70,"sourceCode":"\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            }\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;","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/ClearSnapshot.java#L52-L88","documentation":"clearsnapshot supports two age-based filtering options: --older-than (a duration) and --older-than-timestamp (an ISO instant). They are mutually exclusive; passing both throws this IllegalArgumentException.","triggerScenarios":"Running e.g. `nodetool clearsnapshot --all --older-than 7d --older-than-timestamp 2026-01-01T00:00:00Z`.","commonSituations":"Scripts where both an explicit duration and a computed cutoff timestamp end up in the command line, or users unsure which option is canonical.","solutions":["Keep only --older-than <duration> for relative cutoffs","Keep only --older-than-timestamp <ISO-8601 instant> for absolute cutoffs","Compute one from the other in your script before invoking nodetool"],"exampleFix":"// before\nnodetool clearsnapshot --all --older-than 7d --older-than-timestamp 2026-01-01T00:00:00Z\n// after\nnodetool clearsnapshot --all --older-than 7d","handlingStrategy":"validation","validationCode":"if olderThan and olderThanTimestamp: raise SystemExit(\"pick one of --older-than / --older-than-timestamp\")","typeGuard":null,"tryCatchPattern":"try { clearSnapshot(); }\ncatch (IllegalArgumentException e) { /* fix flags */ }","preventionTips":["Standardize on one cutoff style per script","Compute duration or timestamp, never both","Document flag choices in cleanup scripts"],"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"}