{"record":{"id":"b2bf532f20a3055b","repo":"apache/cassandra","slug":"s-doesn-t-exists","errorCode":null,"errorMessage":"%s doesn't exists","messagePattern":"(.+?) doesn't exists","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java","lineNumber":456,"sourceCode":"         */\n        public Builder inDirectory(String directory)\n        {\n            return inDirectory(new File(directory));\n        }\n\n        /**\n         * The directory where to write the sstables (mandatory option).\n         * <p>\n         * This is a mandatory option.\n         *\n         * @param directory the directory to use, which should exists and be writable.\n         * @return this builder.\n         * @throws IllegalArgumentException if {@code directory} doesn't exist or is not writable.\n         */\n        public Builder inDirectory(File directory)\n        {\n            if (!directory.exists())\n                throw new IllegalArgumentException(directory + \" doesn't exists\");\n            if (!directory.isWritable())\n                throw new IllegalArgumentException(directory + \" exists but is not writable\");\n\n            this.directory = directory;\n            return this;\n        }\n\n        public Builder withType(String typeDefinition) throws SyntaxException\n        {\n            typeStatements.add(QueryProcessor.parseStatement(typeDefinition, CreateTypeStatement.Raw.class, \"CREATE TYPE\"));\n            return this;\n        }\n\n        /**\n         * The schema (CREATE TABLE statement) for the table for which sstable are to be created.\n         * <p>\n         * Please note that the provided CREATE TABLE statement <b>must</b> use a fully-qualified\n         * table name, one that include the keyspace name.","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java#L438-L474","documentation":"Thrown by CQLSSTableWriter.Builder.inDirectory(File) as an IllegalArgumentException when the given directory does not exist on the filesystem. The builder requires a valid, existing output directory before any SSTables can be written. (Note the message text has a known grammar typo: \"doesn't exists\".)","triggerScenarios":"Calling CQLSSTableWriter.builder().inDirectory(new File(\"/path/that/does/not/exist\")) or inDirectory(File) with a path that was deleted after the File handle was created.","commonSituations":"Typos in output paths; assuming inDirectory creates the directory (it does not — use File.mkdir(s) first); relative paths resolved against an unexpected working directory in the bulk-loader environment; container/CI setups where the mount is absent.","solutions":["Create the directory before passing it: new File(dir).mkdirs()","Verify the absolute path with directory.getAbsolutePath() to catch relative-path mistakes","Check mounts/volumes exist when running in containers or CI","Use inDirectory(String) with a verified path and assert existence in setup code"],"exampleFix":"// before\nFile dir = new File(\"/data/sstables/output\");\nCQLSSTableWriter.builder().inDirectory(dir);\n// after\nFile dir = new File(\"/data/sstables/output\");\nif (!dir.exists() && !dir.mkdirs()) throw new IllegalStateException(\"cannot create \" + dir);\nCQLSSTableWriter.builder().inDirectory(dir);","handlingStrategy":"validation","validationCode":"File dir = new File(path); if (!dir.exists()) { if (!dir.mkdirs()) throw new IllegalStateException(\"cannot create \" + dir); }","typeGuard":"null","tryCatchPattern":"try { builder.inDirectory(dir); } catch (IllegalArgumentException e) { // 'doesn't exists' vs 'not writable' — create or fix permissions accordingly }","preventionTips":["Call mkdirs() before inDirectory; the builder does not create directories","Use absolute paths in bulk-loader scripts","Verify directory presence in CI/container provisioning","Wrap builder setup in a precondition check method"],"tags":["sstable","bulk-loading","filesystem","directory"],"backgroundTag":"directory-not-found","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"}