{"record":{"id":"355cfce6ba53247f","repo":"apache/shardingsphere","slug":"30020-355cfc","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/handler/distsql/ral/updatable/imports/ImportMetaDataExecutor.java","lineNumber":56,"sourceCode":"public final class ImportMetaDataExecutor implements DistSQLUpdateExecutor<ImportMetaDataStatement> {\n    \n    @Override\n    public void executeUpdate(final ImportMetaDataStatement sqlStatement, final ContextManager contextManager) {\n        String jsonMetaDataConfig = sqlStatement.getFilePath().isPresent() ? getMetaDataFromFile(sqlStatement) : getMetaDataFromConsole(sqlStatement);\n        ExportedClusterInfo exportedClusterInfo = JsonUtils.fromJsonString(jsonMetaDataConfig, ExportedClusterInfo.class);\n        ExportedMetaData exportedMetaData = exportedClusterInfo.getMetaData();\n        new MetaDataImportExecutor(contextManager).importClusterConfigurations(exportedMetaData);\n    }\n    \n    private String getMetaDataFromFile(final ImportMetaDataStatement sqlStatement) {\n        if (!sqlStatement.getFilePath().isPresent()) {\n            return \"\";\n        }\n        File file = new File(sqlStatement.getFilePath().get());\n        try {\n            return FileUtils.readFileToString(file, Charset.defaultCharset());\n        } catch (final IOException ignore) {\n            throw new FileIOException(file);\n        }\n    }\n    \n    private String getMetaDataFromConsole(final ImportMetaDataStatement sqlStatement) {\n        return new String(Base64.decodeBase64(sqlStatement.getMetaDataValue()));\n    }\n    \n    @Override\n    public Class<ImportMetaDataStatement> getType() {\n        return ImportMetaDataStatement.class;\n    }\n}\n","sourceCodeStart":38,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/imports/ImportMetaDataExecutor.java#L38-L69","documentation":"FileIOException (error code 30020) thrown by ImportMetaDataExecutor.getMetaDataFromFile when reading the file given to IMPORT METADATA fails. If the statement supplies a file path (Optional is present), FileUtils.readFileToString(file, Charset.defaultCharset()) is used; any IOException (missing/unreadable file, broken encoding) is replaced by FileIOException naming the file. This path applies only when filePath is present — the console (base64) variant reads getMetaDataValue() instead.","triggerScenarios":"IMPORT METADATA FROM FILE '/path/metadata.json' (or equivalent) where the path is absent, unreadable, or reading fails with IOException; IMPORT METADATA without a file path does not hit this code.","commonSituations":"Metadata migration between clusters where the exported file was not transferred to the new proxy node; wrong working directory for a relative path; multi-node cluster where only one node has the file.","solutions":["Ensure the metadata file exists on every proxy node that may execute the IMPORT, using an absolute path","Fix read permissions for the proxy process user","Alternatively use the console form (IMPORT METADATA FROM ...) with the base64 content, which bypasses file access entirely"],"exampleFix":"-- before\nIMPORT METADATA FROM FILE 'metadata/export.json';\n\n-- after\nIMPORT METADATA FROM FILE '/opt/shardingsphere/metadata/export.json';","handlingStrategy":"validation","validationCode":"if (statement.getFilePath().isPresent()) {\n    File f = new File(statement.getFilePath().get());\n    if (!f.isFile() || !f.canRead()) {\n        throw new IllegalArgumentException(\"Metadata file unavailable: \" + f.getAbsolutePath());\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Distribute the metadata file to all proxy nodes or use the console (base64) import form","Verify checksum of transferred export files before running IMPORT METADATA"],"tags":["distsql","file-io","ral","import","metadata"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}