{"record":{"id":"71dc202a601221e2","repo":"apache/cassandra","slug":"can-not-take-ephemeral-snapshot-s-while-ttl-is","errorCode":null,"errorMessage":"can not take ephemeral snapshot (%s) while ttl is specified too","messagePattern":"can not take ephemeral snapshot \\((.+?)\\) while ttl is specified too","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/snapshot/SnapshotOptions.java","lineNumber":273,"sourceCode":"            if (!SAFE_SNAPSHOT_NAME.matcher(resolvedSnapshotName).matches())\n            {\n                throw new IllegalArgumentException(\"Snapshot name contains illegal characters: \" + resolvedSnapshotName + \". \" +\n                                                   \"Allowed characters must match the pattern: \" + SAFE_SNAPSHOT_NAME.pattern() +\n                                                   \" with a maximum of length of \" + FILENAME_LENGTH + \" characters.\");\n            }\n        }\n\n        private void validateTTL(boolean ephemeral, DurationSpec.IntSecondsBound ttl)\n        {\n            if (ttl != null)\n            {\n                int minAllowedTtlSecs = CassandraRelevantProperties.SNAPSHOT_MIN_ALLOWED_TTL_SECONDS.getInt();\n                if (ttl.toSeconds() < minAllowedTtlSecs)\n                    throw new IllegalArgumentException(format(\"ttl for snapshot must be at least %d seconds\", minAllowedTtlSecs));\n            }\n\n            if (ephemeral && ttl != null)\n                throw new IllegalStateException(format(\"can not take ephemeral snapshot (%s) while ttl is specified too\", tag));\n        }\n    }\n\n    @Override\n    public String toString()\n    {\n        return \"CreateSnapshotOptions{\" +\n               \"type=\" + type +\n               \", tag='\" + tag + '\\'' +\n               \", ttl=\" + ttl +\n               \", creationTime=\" + creationTime +\n               \", skipFlush=\" + skipFlush +\n               \", ephemeral=\" + ephemeral +\n               \", entities=\" + Arrays.toString(entities) +\n               '}';\n    }\n}\n","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/snapshot/SnapshotOptions.java#L255-L291","documentation":"validateTTL rejects combining an ephemeral snapshot with an explicit ttl, throwing IllegalStateException. Ephemeral snapshots are transient by definition (deleted as soon as their session ends), so attaching a TTL is contradictory. The two options are mutually exclusive at the builder level.","triggerScenarios":"nodetool snapshot --ephemeral --ttl 10m, or SnapshotOptions.builder().ephemeral(true).withTTL(...) — any call where both ephemeral=true and ttl != null reach build().","commonSituations":"Tooling that always sets a default TTL but was switched to ephemeral snapshots; users combining flags assuming TTL governs cleanup of ephemeral snapshots; script parameter merge accidentally passing both.","solutions":["Remove the --ttl flag when taking an ephemeral snapshot.","If TTL-based retention is needed, take a regular (non-ephemeral) snapshot with a ttl instead.","Update wrapper scripts so ephemeral and ttl options are mutually exclusive."],"exampleFix":"// before\nnodetool snapshot --ephemeral -t tmp --ttl 10m\n// after\nnodetool snapshot --ephemeral -t tmp","handlingStrategy":"validation","validationCode":"if (ephemeral && ttl != null) throw new IllegalArgumentException(\"ephemeral snapshots cannot specify ttl\");","typeGuard":null,"tryCatchPattern":"try { takeSnapshot(opts); } catch (IllegalStateException e) { if (e.getMessage().contains(\"ephemeral\")) takeSnapshot(opts.withoutTtl()); else throw e; }","preventionTips":["Treat ephemeral and ttl as mutually exclusive flags in tooling","Document in wrapper scripts that ephemeral implies no ttl","Add config-layer validation before calling the snapshot API"],"tags":["snapshot","ephemeral","ttl","mutually-exclusive"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}