{"record":{"id":"bfe32a8f291b808a","repo":"apache/dolphinscheduler","slug":"tenantcode-s-doesn-t-exist","errorCode":null,"errorMessage":"TenantCode: %s doesn't exist","messagePattern":"TenantCode: (.+?) doesn't exist","errorType":"exception","errorClass":"TaskException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/utils/TenantUtils.java","lineNumber":74,"sourceCode":"\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\n    public static String getBootstrapTenant() {\n        return TenantConstants.BOOTSTRAP_SYSTEM_USER;\n    }\n\n    public static boolean isBootstrapTenant(String tenantCode) {\n        return TenantConstants.BOOTSTRAP_SYSTEM_USER.equals(tenantCode);\n    }\n\n    public static boolean tenantExists(String tenantCode) {\n        return OSUtils.getUserList().contains(tenantCode);","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/utils/TenantUtils.java#L56-L92","documentation":"getOrCreateActualTenant throws TaskException when the tenant (OS user) does not exist on the worker host after any auto-creation attempt. tenantExists(tenantCode) returned false, so the task cannot be executed under that Linux user.","triggerScenarios":"Task has a non-default tenantCode; isAutoCreateTenantEnabled is false (or user creation failed) and tenantExists(tenantCode) is false, i.e. no such Linux user on the worker machine.","commonSituations":"Tenant created in the UI but the matching Linux user was never created on worker nodes; auto-create disabled; user creation failed due to missing sudo/useradd permissions; multi-node cluster where only some workers have the user.","solutions":["Create the OS user on every worker host: useradd <tenantCode>.","Enable tenant-config.auto-create-tenant-enabled=true so workers create the user if absent (requires sudo rights for the worker user).","Ensure the worker process has permission to run useradd (sudoers entry) when auto-creation is on.","Verify the tenant name matches a valid Linux username (no invalid characters)."],"exampleFix":"// before\nsudo useradd -m ds_tenant -s /bin/bash  # run on ALL worker nodes\n// or enable auto-create\n# tenant-config.auto-create-tenant-enabled=true","handlingStrategy":"validation","validationCode":"// on each worker before scheduling\nimport pwd\ntry:\n    pwd.getpwnam(tenant_code)\nexcept KeyError:\n    raise SystemExit(f\"OS user {tenant_code} missing on worker\")","typeGuard":null,"tryCatchPattern":"try { runTask(tenantCode); } catch (TaskException e) { if (e.getMessage().contains(\"doesn't exist\")) createUserOnWorkers(tenantCode); }","preventionTips":["Provision tenant OS users via config management (Ansible/puppet) on every worker","Enable auto-create-tenant with proper sudoers setup","Re-run provisioning when adding worker nodes","Keep UI tenants and OS users in sync"],"tags":["tenant","linux-user","worker","os"],"backgroundTag":"user-not-found","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"}