apache/dolphinscheduler · error · TaskException
Read sql content from resource file %s error
Error message
Read sql content from resource file %s error
What it means
When the SQL task's sqlType content comes from a resource file, ensureSqlContent downloads/reads the resource from local path and reads all bytes as UTF-8. An IOException during this read is wrapped into a TaskException naming the resource path.
Source
Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java:436
return;
}
if (StringUtils.isEmpty(sqlParameters.getSqlResource())) {
return;
}
String resourcePathInStorage = sqlParameters.getSqlResource();
try {
ResourceContext resourceContext = taskExecutionContext.getResourceContext();
ResourceContext.ResourceItem resourceItem =
resourceContext.getResourceItem(resourcePathInStorage);
String localPath = resourceItem.getResourceAbsolutePathInLocal();
log.info("Load sql content from resource file: {}", resourcePathInStorage);
String sqlContent = new String(
Files.readAllBytes(Paths.get(localPath)),
StandardCharsets.UTF_8);
sqlParameters.setSql(sqlContent);
} catch (IOException e) {
log.error("Read sql content from resource file {} error", resourcePathInStorage, e);
throw new TaskException(
String.format("Read sql content from resource file %s error", resourcePathInStorage),
e);
}
}
/**
* ready to execute SQL and parameter entity Map
*
* @return SqlBinds
*/
private SqlBinds getSqlAndSqlParamsMap(String sql) {
Map<Integer, Property> sqlParamsMap = new HashMap<>();
StringBuilder sqlBuilder = new StringBuilder();
// new
// replace variable TIME with $[YYYYmmddd...] in sql when history run job and batch complement job
sql = ParameterUtils.replaceScheduleTime(sql,
DateUtils.timeStampToDate(taskExecutionContext.getScheduleTime()));
View on GitHub (pinned to 02eac45a1b)
Solutions
- Verify the resource file exists in the resource center and the path in the task definition is correct
- Confirm the resource was downloaded to the worker's local path (check tenant config and storage settings)
- Check file permissions and disk space on the worker for the local resource directory
- Re-upload the resource file and re-save the task definition
Example fix
// before // resource: /sqls/etl.sql (deleted from resource center) // after // re-upload etl.sql to resource center and verify task's resource list points to it, // or inline the SQL directly in the SQL editor instead of referencing a file
Defensive patterns
Strategy: validation
Validate before calling
java.nio.file.Path p = Paths.get(localPath);
if (!java.nio.file.Files.exists(p) || !java.nio.file.Files.isReadable(p)) {
throw new IllegalStateException("Resource file missing/unreadable: " + p);
} Try / catch
try {
sqlTask.handle();
} catch (TaskException e) {
if (e.getMessage().startsWith("Read sql content from resource file")) {
// re-sync/re-upload the resource and retry
}
} Prevention
- Verify resource files exist in the resource center before scheduling
- Ensure storage settings and tenant dirs are consistent across workers
- Prefer inlining SQL in the task editor for small scripts
When it happens
Trigger: The resource file referenced in the task (resourcePathInStorage) does not exist at the resolved local path, permissions deny reading, or the storage download step failed leaving no local file.
Common situations: Resource deleted or renamed in the resource center after the task was defined; wrong tenant/home directory so downloaded resources land elsewhere; worker disk full or permissions issue; multi-cluster setup where the resource wasn't synced to this worker.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- Read file: %s error
- Create xlsx directory error
- generate excel error
- Update the resource file from content: {fileAbsolutePath} fa
- Download the resource file: {fileAbsolutePath} failed
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/f240802f51516885.
Report an issue: GitHub.