{"record":{"id":"7bf7d8264c2875aa","repo":"apache/dolphinscheduler","slug":"10164","errorCode":"10164","errorMessage":"Tenant code invalid, should follow linux's users naming conventions","messagePattern":"Tenant code invalid, should follow linux's users naming conventions","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java","lineNumber":92,"sourceCode":"\n    @Autowired\n    private UserDao userDao;\n\n    @Autowired\n    private QueueService queueService;\n\n    /**\n     * Check the tenant new object valid or not\n     *\n     * @param tenant The tenant object want to create\n     */\n    private void createTenantValid(Tenant tenant) throws ServiceException {\n        if (StringUtils.isEmpty(tenant.getTenantCode())) {\n            throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR, tenant.getTenantCode());\n        } else if (StringUtils.length(tenant.getTenantCode()) > TENANT_FULL_NAME_MAX_LENGTH) {\n            throw new ServiceException(Status.TENANT_FULL_NAME_TOO_LONG_ERROR);\n        } else if (!RegexUtils.isValidLinuxUserName(tenant.getTenantCode())) {\n            throw new ServiceException(Status.CHECK_OS_TENANT_CODE_ERROR);\n        } else if (checkTenantExists(tenant.getTenantCode())) {\n            throw new ServiceException(Status.OS_TENANT_CODE_EXIST, tenant.getTenantCode());\n        }\n    }\n\n    /**\n     * Check tenant update object valid or not\n     *\n     * @param existsTenant The exists queue object\n     * @param updateTenant The queue object want to update\n     */\n    private void updateTenantValid(Tenant existsTenant, Tenant updateTenant) throws ServiceException {\n        // Check the exists tenant\n        if (Objects.isNull(existsTenant)) {\n            log.error(\"Tenant does not exist.\");\n            throw new ServiceException(Status.TENANT_NOT_EXIST);\n        }\n        // Check the update tenant parameters","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java#L74-L110","documentation":"Status.CHECK_OS_TENANT_CODE_ERROR from createTenantValid: tenantCode fails RegexUtils.isValidLinuxUserName, so it does not conform to Linux user naming conventions (must start with a lowercase letter or underscore, contain only lowercase alphanumerics/underscores/hyphens, no leading digit or hyphen). Because the tenant code becomes an OS user, invalid names would fail at worker-node provisioning.","triggerScenarios":"Creating/updating a tenant with codes containing uppercase letters, spaces, dots, Chinese/unicode characters, leading digits or hyphens, or other special characters.","commonSituations":"Using company email prefixes with dots ('john.doe'); auto-deriving tenants from group names with uppercase ('DevTeam'); copy-pasting names with trailing spaces or special characters.","solutions":["Convert the tenantCode to a valid Linux user name: lowercase, replace invalid chars with '-' or '_', strip leading digits/hyphens.","Validate with a regex like ^[a-z_][a-z0-9_-]{0,63}$ before calling the API.","Pre-create the OS user on worker nodes with the sanitized name if provisioning manually.","Document a naming convention so teams request compliant tenant codes."],"exampleFix":"// before\nString tenantCode = \"John.Doe@Corp\"; // invalid: uppercase, dot, @\n// after\nString tenantCode = \"john-doe-corp\".toLowerCase().replaceAll(\"[^a-z0-9_-]\", \"-\").replaceFirst(\"^[0-9-]+\", \"\");","handlingStrategy":"validation","validationCode":"if (tenantCode == null || !tenantCode.matches(\"^[a-z_][a-z0-9_-]{0,63}$\")) {\n    throw new IllegalArgumentException(\"tenantCode must match Linux user naming rules\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    tenantService.createTenant(loginUser, tenantCode, desc, queueId);\n} catch (ServiceException e) {\n    if (e.getCode() == 10164) { /* sanitize tenantCode (lowercase, replace invalid chars) and retry */ }\n}","preventionTips":["Sanitize codes: lowercase, [a-z0-9_-] only, no leading digit/hyphen","Validate with the Linux-username regex before any tenant API call","Document the naming convention for teams","Strip whitespace and unicode from SSO-derived names"],"tags":["validation","tenant","linux-naming","regex"],"backgroundTag":"invalid-identifier-format","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"}