{"record":{"id":"17836f6f996aa720","repo":"apache/dolphinscheduler","slug":"the-tenantcode-is","errorCode":null,"errorMessage":"The tenantCode is ","messagePattern":"The tenantCode is ","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/utils/TenantUtils.java","lineNumber":64,"sourceCode":"     * <p>\n     * If sudo is not enabled, will not check the tenant code.\n     */\n    public static String getOrCreateActualTenant(WorkerConfig workerConfig, TaskExecutionContext taskExecutionContext) {\n        TenantConfig tenantConfig = workerConfig.getTenantConfig();\n\n        if (!isTenantEnable()) {\n            log.info(\"Tenant is not enabled, will use the bootstrap: {} user as tenant\", getBootstrapTenant());\n            return getBootstrapTenant();\n        }\n\n        String tenantCode = taskExecutionContext.getTenantCode();\n        if (isDefaultTenant(tenantCode)) {\n            if (tenantConfig.isDefaultTenantEnabled()) {\n                log.info(\"Current tenant is default tenant, will use bootstrap user: {} to execute the task\",\n                        getBootstrapTenant());\n                return getBootstrapTenant();\n            } else {\n                throw new TaskException(\n                        \"The tenantCode is \" + tenantCode + \", please enable TenantConfig#isDefaultTenantEnabled\");\n            }\n        }\n\n        if (tenantConfig.isAutoCreateTenantEnabled()) {\n            OSUtils.createUserIfAbsent(tenantCode);\n        }\n\n        if (!tenantExists(tenantCode)) {\n            throw new TaskException(String.format(\"TenantCode: %s doesn't exist\", tenantCode));\n        }\n        return tenantCode;\n    }\n\n    public static boolean isDefaultTenant(String tenantCode) {\n        return TenantConstants.DEFAULT_TENANT_CODE.equals(tenantCode);\n    }\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/utils/TenantUtils.java#L46-L82","documentation":"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.","triggerScenarios":"A task/workflow is assigned tenantCode 'default' (TenantConstants.DEFAULT_TENANT_CODE) and tenantConfig.isDefaultTenantEnabled() is false, hitting the else branch of isDefaultTenant(tenantCode).","commonSituations":"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.","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."],"exampleFix":"// before\n# worker config\ntenant-config.is-default-tenant-enabled=false  // task uses tenant 'default'\n// after\ntenant-config.is-default-tenant-enabled=true","handlingStrategy":"validation","validationCode":"boolean ok = !\"default\".equals(tenantCode) || tenantConfig.isDefaultTenantEnabled();\nif (!ok) throw new IllegalStateException(\"enable is-default-tenant-enabled or assign a real tenant\");","typeGuard":null,"tryCatchPattern":"try { submitWorkflow(tenant); } catch (TaskException e) { if (e.getMessage().contains(\"isDefaultTenantEnabled\")) reassignTenantAndRetry(); }","preventionTips":["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"],"tags":["tenant","configuration","worker"],"backgroundTag":"feature-not-enabled","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}