apache/dolphinscheduler · error · ServiceException
10164
10164
Error message
Tenant code invalid, should follow linux's users naming conventions
What it means
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.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java:92
@Autowired
private UserDao userDao;
@Autowired
private QueueService queueService;
/**
* Check the tenant new object valid or not
*
* @param tenant The tenant object want to create
*/
private void createTenantValid(Tenant tenant) throws ServiceException {
if (StringUtils.isEmpty(tenant.getTenantCode())) {
throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR, tenant.getTenantCode());
} else if (StringUtils.length(tenant.getTenantCode()) > TENANT_FULL_NAME_MAX_LENGTH) {
throw new ServiceException(Status.TENANT_FULL_NAME_TOO_LONG_ERROR);
} else if (!RegexUtils.isValidLinuxUserName(tenant.getTenantCode())) {
throw new ServiceException(Status.CHECK_OS_TENANT_CODE_ERROR);
} else if (checkTenantExists(tenant.getTenantCode())) {
throw new ServiceException(Status.OS_TENANT_CODE_EXIST, tenant.getTenantCode());
}
}
/**
* Check tenant update object valid or not
*
* @param existsTenant The exists queue object
* @param updateTenant The queue object want to update
*/
private void updateTenantValid(Tenant existsTenant, Tenant updateTenant) throws ServiceException {
// Check the exists tenant
if (Objects.isNull(existsTenant)) {
log.error("Tenant does not exist.");
throw new ServiceException(Status.TENANT_NOT_EXIST);
}
// Check the update tenant parametersView on GitHub (pinned to 02eac45a1b)
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.
Example fix
// before
String tenantCode = "John.Doe@Corp"; // invalid: uppercase, dot, @
// after
String tenantCode = "john-doe-corp".toLowerCase().replaceAll("[^a-z0-9_-]", "-").replaceFirst("^[0-9-]+", ""); Defensive patterns
Strategy: validation
Validate before calling
if (tenantCode == null || !tenantCode.matches("^[a-z_][a-z0-9_-]{0,63}$")) {
throw new IllegalArgumentException("tenantCode must match Linux user naming rules");
} Try / catch
try {
tenantService.createTenant(loginUser, tenantCode, desc, queueId);
} catch (ServiceException e) {
if (e.getCode() == 10164) { /* sanitize tenantCode (lowercase, replace invalid chars) and retry */ }
} Prevention
- 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
When it happens
Trigger: Creating/updating a tenant with codes containing uppercase letters, spaces, dots, Chinese/unicode characters, leading digits or hyphens, or other special characters.
Common situations: 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.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/7bf7d8264c2875aa.
Report an issue: GitHub.