{"record":{"id":"5cec7050678b3e76","repo":"prestodb/presto","slug":"configured-staging-path-is-not-a-directory","errorCode":null,"errorMessage":"Configured staging path is not a directory: ","messagePattern":"Configured staging path is not a directory: ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java","lineNumber":440,"sourceCode":"        return new FSDataInputStream(\n                new BufferedFSInputStream(\n                        new PrestoS3InputStream(s3, getBucketName(uri), path, maxAttempts, maxBackoffTime, maxRetryTime),\n                        bufferSize));\n    }\n\n    @Override\n    public FSDataOutputStream create(Path path, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress)\n            throws IOException\n    {\n        if ((!overwrite) && exists(path)) {\n            throw new IOException(\"File already exists:\" + path);\n        }\n\n        if (!stagingDirectory.exists()) {\n            createDirectories(stagingDirectory.toPath());\n        }\n        if (!stagingDirectory.isDirectory()) {\n            throw new IOException(\"Configured staging path is not a directory: \" + stagingDirectory);\n        }\n        File tempFile = createTempFile(stagingDirectory.toPath(), \"presto-s3-\", \".tmp\").toFile();\n\n        String key = keyFromPath(qualifiedPath(path));\n        return new FSDataOutputStream(\n                new PrestoS3OutputStream(s3,\n                        getBucketName(uri),\n                        key,\n                        tempFile,\n                        sseEnabled,\n                        sseType,\n                        sseKmsKeyId,\n                        multiPartUploadMinFileSize,\n                        multiPartUploadMinPartSize,\n                        s3AclType,\n                        s3StorageClass),\n                statistics);\n    }","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java#L422-L458","documentation":"create() validates the configured staging directory (where multipart-upload temp files are buffered locally) and throws if it exists but is not a directory. The hive.s3.staging-directory setting points at a regular file or an invalid filesystem entry.","triggerScenarios":"hive.s3.staging-directory (or s3.staging-directory Hadoop config) resolved to a path that is a file; a mount point replaced by a file; wrong path substitution in configs.","commonSituations":"Config typo where staging dir points at a file (e.g. a symlink to a file); Docker/K8s volume mounted over the directory as a file; leftover artifact from packaging.","solutions":["Fix the staging-directory config to point to a real directory (e.g. /tmp/presto-s3-staging).","Remove or rename the offending file at that path and let Presto recreate the directory.","Ensure the Presto process user has write permission on the staging parent.","Re-check after container/volume changes that the mount is a directory."],"exampleFix":"// before (properties)\nhive.s3.staging-directory=/etc/presto/s3-staging.cfg   // a file\n// after\nhive.s3.staging-directory=/tmp/presto-s3-staging","handlingStrategy":"validation","validationCode":"java.io.File staging = new java.io.File(config.get(\"hive.s3.staging-directory\"));\nif (staging.exists() && !staging.isDirectory()) {\n    throw new IllegalStateException(\"staging path is a file: \" + staging);\n}\nif (!staging.exists() && !staging.mkdirs()) {\n    throw new IllegalStateException(\"cannot create staging dir: \" + staging);\n}","typeGuard":"boolean isUsableStagingDir(java.io.File f) {\n    return f.isDirectory() && f.canWrite();\n}","tryCatchPattern":"try {\n    out = fs.create(path, ...);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"not a directory\")) {\n        // fix hive.s3.staging-directory config or remove the offending file\n    }\n    throw e;\n}","preventionTips":["Point staging-directory at a dedicated writable directory (e.g. /tmp/presto-s3-staging).","Check volume/mount configs in containers so the path remains a directory.","Verify permissions for the Presto service user.","Include staging-dir checks in deployment smoke tests."],"tags":["s3","configuration","staging-directory","io"],"backgroundTag":"invalid-config-path","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}