apache/dolphinscheduler · error · IOException

Error reading file: ${filePath}

Error message

Error reading file: ${filePath}

What it means

DmsHook.replaceFileParameters() resolves task parameters of the form 'file://<path>' by reading the file's UTF-8 contents inline. If the FileInputStream/IOUtils.read throws IOException (file missing, unreadable), it rethrows with 'Error reading file: <path>' plus the cause. This indicates a DMS replication-task config references a file the worker cannot read.

Source

Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-dms/src/main/java/org/apache/dolphinscheduler/plugin/task/dms/DmsHook.java:274

                return true;
            } else if (stopStatusSet.contains(status)) {
                break;
            }
        }
        log.info("error");
        return false;
    }

    public String replaceFileParameters(String parameter) throws IOException {
        if (parameter == null) {
            return null;
        }
        if (parameter.startsWith("file://")) {
            String filePath = parameter.substring(7);
            try {
                return IOUtils.toString(new FileInputStream(filePath), StandardCharsets.UTF_8);
            } catch (IOException e) {
                throw new IOException("Error reading file: " + filePath, e);
            }
        }
        return parameter;
    }

    public ApplicationIds getApplicationIds() {
        return new ApplicationIds(replicationTaskArn);
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class ApplicationIds {

        private String replicationTaskArn;
    }

    public static class STATUS {

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Verify the file exists at the exact path on the worker: check the path printed in the error message.
  2. Confirm the resource was attached to the task so it is downloaded to the execution directory before submit.
  3. Check file permissions for the worker OS user (read access on file and parent dirs).
  4. Correct the file:// parameter to point to an existing file, then rerun.

Example fix

// before: missing file
"s3_properties": "file://./missing-s3.properties"
// after: ensure resource attached and path correct
"s3_properties": "file://./s3.properties" // with s3.properties attached as task resource
Defensive patterns

Strategy: validation

Validate before calling

String path = param.startsWith("file://") ? param.substring(7) : null;
java.io.File f = new java.io.File(path);
boolean readable = f != null && f.isFile() && f.canRead();

Type guard

boolean isReadableFileParam(String param) {
    if (!param.startsWith("file://")) return true;
    java.io.File f = new java.io.File(param.substring(7));
    return f.isFile() && f.canRead();
}

Try / catch

try {
    dmsTask.submitApplication();
} catch (Exception e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Error reading file:")) {
        log.error("Missing/unreadable file resource: {}", e.getMessage());
    }
}

Prevention

When it happens

Trigger: A DMS task parameter starts with 'file://' but the path after it does not exist, is a directory, or is not readable by the worker process (IOException from FileInputStream or IOUtils.toString).

Common situations: Resource file not downloaded to the worker execution directory; typo in the file:// path; file created after task start; permissions changed on shared storage.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/4bfc4301550de4d8. Report an issue: GitHub.