{"record":{"id":"b305ac0de3fa200d","repo":"apache/cassandra","slug":"you-must-supply-a-snapshot-name","errorCode":null,"errorMessage":"You must supply a snapshot name.","messagePattern":"You must supply a snapshot name\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/snapshot/SnapshotOptions.java","lineNumber":216,"sourceCode":"            this.rateLimiter = rateLimiter;\n            return this;\n        }\n\n        public SnapshotOptions build()\n        {\n            validateTag(tag);\n            validateTTL(ephemeral, ttl);\n\n            if (rateLimiter == null)\n                rateLimiter = DatabaseDescriptor.getSnapshotRateLimiter();\n\n            return new SnapshotOptions(this);\n        }\n\n        private void validateTag(String tag)\n        {\n            if (tag == null || tag.isEmpty())\n                throw new IllegalArgumentException(\"You must supply a snapshot name.\");\n\n            if (tag.contains(File.pathSeparator()))\n            {\n                throw new IllegalArgumentException(\"Snapshot name cannot contain \" + File.pathSeparator());\n            }\n\n            if (tag.equals(\".\") || tag.equals(\"..\"))\n            {\n                throw new IllegalArgumentException(\"Snapshot name '\" + tag + \"' is reserved\");\n            }\n\n            if (!CassandraRelevantProperties.SNAPSHOT_NAME_VALIDATION.getBoolean())\n                return;\n\n            // Pre-generate snapshot name for the sake of the validation.\n            // getSnapshotName logic does not return raw \"tag\" as snapshot name every time,\n            // it e.g. prepends timestamp and type for system snapshots, and we need to validate it as a whole.\n            // If, for example, tag would be less than max allowed FILENAME_LENGTH,","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/snapshot/SnapshotOptions.java#L198-L234","documentation":"SnapshotOptions.Builder.validateTag rejects null or empty snapshot tags with an IllegalArgumentException before building options. A snapshot name is mandatory because it becomes the snapshot directory name.","triggerScenarios":"Building SnapshotOptions (or calling takeSnapshot paths) without supplying a tag; passing an empty string tag from a config-driven or scripted invocation.","commonSituations":"Automation where the tag variable is unset or substituted to empty; API/JMX callers omitting the snapshot name parameter.","solutions":["Supply a non-empty snapshot name to the builder/command (e.g. -t mytag for nodetool snapshot).","Default missing tags in your script, e.g. \"backup-$(date +%s)\".","Validate tag presence before invoking the snapshot API and fail fast with a clear message.","Check config/templating so empty values do not silently drop the tag argument."],"exampleFix":"// before\nString tag = System.getProperty(\"snapshot.tag\"); // may be null\nbuilder.withTag(tag).build();\n// after\nString tag = System.getProperty(\"snapshot.tag\", \"backup-\" + System.currentTimeMillis());\nif (tag == null || tag.isEmpty()) throw new IllegalArgumentException(\"snapshot.tag is required\");\nbuilder.withTag(tag).build();","handlingStrategy":"validation","validationCode":"String requireTag(String tag) { if (tag == null || tag.isEmpty()) throw new IllegalArgumentException(\"snapshot tag is required\"); return tag; }","typeGuard":null,"tryCatchPattern":"try { builder.withTag(tag).build(); } catch (IllegalArgumentException e) { log.error(\"Snapshot tag missing: {}\", e.getMessage()); }","preventionTips":["Check tag variables are set before scripting snapshot calls","Provide default generated tags","Fail fast in scripts with set -u / explicit null checks"],"tags":["snapshot","validation","illegalargument","missing-argument"],"backgroundTag":"missing-required-argument","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"}