apache/dolphinscheduler · error · TaskException

Failed to get template info

Error message

Failed to get template info

What it means

In handle(), the task fetches template info via aliyunServerlessSparkClient.getTemplate, wrapped in RetryUtils.retryFunction; any exception inside is wrapped as TaskException "Failed to get template info" and retried per the retryPolicy before ultimately failing the task.

Source

Thrown at dolphinscheduler-task-plugin/dolphinscheduler-task-aliyunserverlessspark/src/main/java/org/apache/dolphinscheduler/plugin/task/aliyunserverlessspark/AliyunServerlessSparkTask.java:135

            aliyunServerlessSparkClient =
                    buildAliyunServerlessSparkClient(accessKeyId, accessKeySecret, regionId, endpoint);
        } catch (Exception e) {
            log.error("Failed to build Aliyun-Serverless-Spark client!", e);
            throw new AliyunServerlessSparkTaskException("Failed to build Aliyun-Serverless-Spark client!");
        }

        currentState = RunState.Submitted;
    }

    @Override
    public void handle(TaskCallBack taskCallBack) throws TaskException {
        GetTemplateResponse getTemplateResponse = RetryUtils.retryFunction(() -> {
            try {
                return aliyunServerlessSparkClient.getTemplate(
                        aliyunServerlessSparkParameters.getWorkspaceId(),
                        buildGetTemplateRequest());
            } catch (Exception e) {
                throw new TaskException("Failed to get template info", e);
            }
        }, retryPolicy);

        if (getTemplateResponse != null) {
            templateConf = getTemplateResponse.getBody()
                    .getData()
                    .getSparkConf()
                    .stream()
                    .map(item -> "--conf " + item.getKey() + "=" + item.getValue())
                    .collect(Collectors.joining(" "));

            templateDisplayReleaseVersion = getTemplateResponse.getBody().getData().getDisplaySparkVersion();
            templateFusion = getTemplateResponse.getBody().getData().getFusion();
        }

        StartJobRunRequest startJobRunRequest = buildStartJobRunRequest(aliyunServerlessSparkParameters);
        StartJobRunResponse startJobRunResponse = RetryUtils.retryFunction(() -> {
            try {

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Verify workspaceId and the template request (job template name/id) exist in the workspace
  2. Check credentials/IAM permission for emr:GetTemplate
  3. Inspect the wrapped cause (retry logs) to distinguish auth vs network vs throttling
  4. Confirm endpoint reachability from the worker; add address to allowlist if firewalled
Defensive patterns

Strategy: retry

Validate before calling

// Pre-flight: confirm workspace and template are reachable with current credentials
GetTemplateResponse r = client.getTemplate(workspaceId, buildGetTemplateRequest()); // fail fast outside retry if config wrong
if (r == null || r.getBody() == null) throw new IllegalStateException("Template missing in workspace " + workspaceId);

Try / catch

try {
    task.handle();
} catch (TaskException e) {
    if (e.getMessage().contains("Failed to get template info")) {
        // inspect cause: auth vs not-found vs network; adjust creds/params before retry
    }
}

Prevention

When it happens

Trigger: getTemplate call throwing — invalid workspaceId, template not found, expired/insufficient credentials (AccessDenied), network error, or API rate limiting — after exhausting retries.

Common situations: Wrong workspaceId or deleted job template in the parameters; RAM/token permissions lacking GetTemplate; Aliyun API throttling; worker host cannot reach the endpoint.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


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