{"record":{"id":"254f4c742c2eeb8e","repo":"apache/shardingsphere","slug":"30020-254f4c","errorCode":"30020","errorMessage":"File access failed, file is: %s","messagePattern":"File access failed, file is: (.+?)","errorType":"exception","errorClass":"FileIOException","httpStatus":null,"severity":"error","filePath":"proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/ExportUtils.java","lineNumber":53,"sourceCode":"    \n    /**\n     * Export configuration data to specified file.\n     *\n     * @param filePath file path\n     * @param exportedData exported configuration data\n     * @throws FileIOException file IO exception\n     */\n    @SuppressWarnings(\"ResultOfMethodCallIgnored\")\n    public static void exportToFile(final String filePath, final String exportedData) {\n        File file = new File(filePath);\n        if (!file.exists() && null != file.getParentFile()) {\n            file.getParentFile().mkdirs();\n        }\n        try (OutputStream output = Files.newOutputStream(Paths.get(file.toURI()))) {\n            output.write(exportedData.getBytes());\n            output.flush();\n        } catch (final IOException ignore) {\n            throw new FileIOException(file);\n        }\n    }\n}\n","sourceCodeStart":35,"sourceCodeEnd":57,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/util/ExportUtils.java#L35-L57","documentation":"FileIOException (error code 30020) thrown by ExportUtils.exportToFile when writing exported data to the given path fails: parent directories are created if missing, then the bytes are written via Files.newOutputStream; any IOException (permission denied, non-directory parent, disk full) is caught and converted to FileIOException naming the file.","triggerScenarios":"EXPORT operations (e.g. EXPORT DATABASE CONFIGURATION / metadata export) targeting a path where mkdirs() failed or the open/write fails: unwritable directory, path is an existing directory, read-only filesystem, or no space left.","commonSituations":"Exporting to /tmp or a config dir not writable by the proxy user; running the proxy in a container with a read-only root filesystem; passing a path whose parent exists as a regular file; disk exhaustion on the proxy host.","solutions":["Choose an export directory that exists and is writable by the proxy process (pre-create it and chown/chmod appropriately)","In containers, export to a mounted writable volume, not the image root","Check disk space on the proxy host and retry after freeing space"],"exampleFix":"-- before\nEXPORT DATABASE CONFIGURATION TO '/etc/shardingsphere/export.yaml';\n\n-- after\nEXPORT DATABASE CONFIGURATION TO '/opt/shardingsphere/export/export.yaml';","handlingStrategy":"validation","validationCode":"File dir = targetFile.getParentFile();\nif (dir == null || (!dir.exists() && !dir.mkdirs()) || !dir.canWrite()) {\n    throw new IllegalArgumentException(\"Export directory not writable: \" + dir);\n}\nif (targetFile.exists() && targetFile.isDirectory()) {\n    throw new IllegalArgumentException(\"Export target is a directory: \" + targetFile);\n}","typeGuard":null,"tryCatchPattern":"try {\n    ExportUtils.exportToFile(path, data);\n} catch (final FileIOException ex) {\n    // surface the path; switch to a writable directory and retry\n}","preventionTips":["Pre-create and chmod the export directory for the proxy user","In containers, always export to a mounted volume; check disk space before large exports"],"tags":["file-io","export","distsql","permissions","proxy"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}