apache/shardingsphere · error · FileIOException

30020

30020

Error message

File access failed, file is: %s

What it means

FileIOException (error code 30020) thrown by ConvertYamlConfigurationExecutor.getRows when YamlEngine.unmarshal(file, YamlProxyDatabaseConfiguration.class) raises IOException while reading the file passed to CONVERT YAML CONFIGURATION. The IOException is swallowed (`ignore`) and replaced with this exception naming the file, so the original I/O reason (missing file, permission, encoding) is not visible in the message.

Source

Thrown at proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/yaml/ConvertYamlConfigurationExecutor.java:74

 * Convert YAML configuration executor.
 */
public final class ConvertYamlConfigurationExecutor implements DistSQLQueryExecutor<ConvertYamlConfigurationStatement> {
    
    private final YamlProxyDataSourceConfigurationSwapper dataSourceConfigSwapper = new YamlProxyDataSourceConfigurationSwapper();
    
    @Override
    public Collection<String> getColumnNames(final ConvertYamlConfigurationStatement statement) {
        return Collections.singleton("dist_sql");
    }
    
    @Override
    public Collection<LocalDataQueryResultRow> getRows(final ConvertYamlConfigurationStatement sqlStatement, final ContextManager contextManager) {
        File file = new File(sqlStatement.getFilePath());
        YamlProxyDatabaseConfiguration yamlConfig;
        try {
            yamlConfig = YamlEngine.unmarshal(file, YamlProxyDatabaseConfiguration.class);
        } catch (final IOException ignore) {
            throw new FileIOException(file);
        }
        Preconditions.checkNotNull(yamlConfig, "Invalid yaml file `%s`", file.getName());
        Preconditions.checkNotNull(yamlConfig.getDatabaseName(), "`databaseName` in file `%s` is required.", file.getName());
        DatabaseNameValidator.validate(yamlConfig.getDatabaseName());
        return Collections.singleton(new LocalDataQueryResultRow(convertYamlConfigurationToDistSQL(yamlConfig)));
    }
    
    @SuppressWarnings("unchecked")
    private String convertYamlConfigurationToDistSQL(final YamlProxyDatabaseConfiguration yamlConfig) {
        StringBuilder result = new StringBuilder();
        result.append(convertDatabase(yamlConfig.getDatabaseName()));
        result.append(System.lineSeparator()).append(System.lineSeparator());
        if (null == yamlConfig.getDataSources() || yamlConfig.getDataSources().isEmpty()) {
            return result.toString();
        }
        result.append(convertDataSources(yamlConfig.getDataSources()));
        result.append(System.lineSeparator()).append(System.lineSeparator());
        if (null == yamlConfig.getRules() || yamlConfig.getRules().isEmpty()) {

View on GitHub (pinned to e952770a21)

Solutions

  1. Verify the file exists and is readable by the proxy process (absolute path is safest); if running in Docker/K8s, confirm the path is mounted into the container
  2. Re-run with an absolute path from the proxy's working directory perspective
  3. If the file exists, check OS-level read permission for the user running ShardingSphere-Proxy

Example fix

-- before
CONVERT YAML CONFIGURATION 'config/db.yaml';

-- after
CONVERT YAML CONFIGURATION '/opt/shardingsphere/conf/db.yaml';
Defensive patterns

Strategy: validation

Validate before calling

File f = new File(path);
if (!f.isFile() || !f.canRead()) {
    throw new IllegalArgumentException("YAML file missing or unreadable: " + f.getAbsolutePath());
}
// safe to submit: CONVERT YAML CONFIGURATION '<path>'

Prevention

When it happens

Trigger: CONVERT YAML CONFIGURATION '/path/to/file.yaml' where the path does not exist, is a directory, or is unreadable by the proxy process; YamlEngine.unmarshal throws IOException during stream reading.

Common situations: Relative path resolved against the proxy working directory instead of the user's shell; file on a mount not visible inside a Docker container; file permissions denying the proxy OS user; typo in the path.

Related errors


AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14). Data as JSON: /api/errors/6738418eb16adfb2. Report an issue: GitHub.