apache/dolphinscheduler · error · TaskException
The tenantCode is
Error message
The tenantCode is
What it means
getOrCreateActualTenant throws TaskException when the task's tenantCode is the default tenant ('default') but TenantConfig#isDefaultTenantEnabled is false. DolphinScheduler refuses to fall back to the bootstrap user, so the task cannot run.
Source
Thrown at dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/utils/TenantUtils.java:64
* <p>
* If sudo is not enabled, will not check the tenant code.
*/
public static String getOrCreateActualTenant(WorkerConfig workerConfig, TaskExecutionContext taskExecutionContext) {
TenantConfig tenantConfig = workerConfig.getTenantConfig();
if (!isTenantEnable()) {
log.info("Tenant is not enabled, will use the bootstrap: {} user as tenant", getBootstrapTenant());
return getBootstrapTenant();
}
String tenantCode = taskExecutionContext.getTenantCode();
if (isDefaultTenant(tenantCode)) {
if (tenantConfig.isDefaultTenantEnabled()) {
log.info("Current tenant is default tenant, will use bootstrap user: {} to execute the task",
getBootstrapTenant());
return getBootstrapTenant();
} else {
throw new TaskException(
"The tenantCode is " + tenantCode + ", please enable TenantConfig#isDefaultTenantEnabled");
}
}
if (tenantConfig.isAutoCreateTenantEnabled()) {
OSUtils.createUserIfAbsent(tenantCode);
}
if (!tenantExists(tenantCode)) {
throw new TaskException(String.format("TenantCode: %s doesn't exist", tenantCode));
}
return tenantCode;
}
public static boolean isDefaultTenant(String tenantCode) {
return TenantConstants.DEFAULT_TENANT_CODE.equals(tenantCode);
}
View on GitHub (pinned to 02eac45a1b)
Solutions
- Set tenant-config.is-default-tenant-enabled=true in worker configuration, or
- Reassign the workflow/task definition to a real (non-default) OS tenant that exists on worker hosts.
- If auto-creating tenants, enable tenant-config.auto-create-tenant-enabled so the tenant OS user exists.
- Restart/redeploy worker after changing TenantConfig.
Example fix
// before # worker config tenant-config.is-default-tenant-enabled=false // task uses tenant 'default' // after tenant-config.is-default-tenant-enabled=true
Defensive patterns
Strategy: validation
Validate before calling
boolean ok = !"default".equals(tenantCode) || tenantConfig.isDefaultTenantEnabled();
if (!ok) throw new IllegalStateException("enable is-default-tenant-enabled or assign a real tenant"); Try / catch
try { submitWorkflow(tenant); } catch (TaskException e) { if (e.getMessage().contains("isDefaultTenantEnabled")) reassignTenantAndRetry(); } Prevention
- Never leave workflows on the 'default' tenant in production
- Set is-default-tenant-enabled explicitly and document it
- Audit workflow definitions for default tenant usage
- Keep worker TenantConfig consistent across the cluster
When it happens
Trigger: A task/workflow is assigned tenantCode 'default' (TenantConstants.DEFAULT_TENANT_CODE) and tenantConfig.isDefaultTenantEnabled() is false, hitting the else branch of isDefaultTenant(tenantCode).
Common situations: Workflow saved with the default tenant while worker config disables default-tenant execution; migration from setups where 'default' tenant was acceptable; missing tenant configuration on the workflow.
Related errors
- TenantCode: %s doesn't exist
- receivers must not be null
- url can not be null
- headerParams is not a valid json
- bodyParams is not a valid json
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/17836f6f996aa720.
Report an issue: GitHub.