apache/dolphinscheduler · error · ServiceException
10017
10017
Error message
tenant [{tenantId}] not exists What it means
Thrown by UsersServiceImpl.createUser when the tenantId supplied in the create-user request does not match any tenant row in the database (checkTenantExists returns false). DolphinScheduler requires every user to belong to a valid tenant (a OS user used to run worker tasks), so creation is refused rather than leaving a dangling reference. It is a user-input/data-referential-integrity error, not a system failure.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java:137
String userPassword,
String email,
int tenantId,
String phone,
String queue,
int state) throws Exception {
if (!isAdmin(loginUser)) {
throw new ServiceException(Status.USER_NO_OPERATION_PERM);
}
// check all user params
String msg = this.checkUserParams(userName, userPassword, email, phone);
if (!StringUtils.isEmpty(msg)) {
throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR, msg);
}
if (!checkTenantExists(tenantId)) {
log.warn("Tenant does not exist, tenantId:{}.", tenantId);
throw new ServiceException(Status.TENANT_NOT_EXIST);
}
User user = createUser(userName, userPassword, email, tenantId, phone, queue, state);
log.info("User is created and id is {}.", user.getId());
return user;
}
@Override
@Transactional
public User createUser(String userName,
String userPassword,
String email,
int tenantId,
String phone,
String queue,
int state) {
User user = new User();
Date now = new Date();View on GitHub (pinned to 02eac45a1b)
Solutions
- Query GET /tenants/list (or the t_ds_tenant table) and use an existing tenant id in the request
- Create the missing tenant first via the tenant management API/UI, then retry user creation
- If automating, fetch tenantId dynamically by tenant name instead of hard-coding
- Verify you are operating against the intended environment's database (ids differ across installs)
Example fix
// before
apiClient.createUser("alice", "pwd", "a@b.c", 42, ...); // hard-coded tenantId
// after
List<Tenant> tenants = apiClient.listTenants();
int tenantId = tenants.stream().filter(t -> t.getTenantName().equals("dev")).findFirst()
.orElseThrow(() -> new IllegalArgumentException("tenant 'dev' missing; create it first")).getId();
apiClient.createUser("alice", "pwd", "a@b.c", tenantId, ...); Defensive patterns
Strategy: validation
Validate before calling
// Java, before calling createUser
boolean tenantExists = tenantsService.checkTenantExists(tenantId); // or query tenant list
if (!tenantExists) {
throw new IllegalArgumentException("tenantId " + tenantId + " does not exist; create it first");
}
usersService.createUser(userName, password, email, tenantId, phone, queue, state); Type guard
// resolve and narrow to a validated tenant id
Integer resolveTenantId(Integer tenantId, List<Tenant> tenants) {
return (tenantId != null && tenants.stream().anyMatch(t -> t.getId().equals(tenantId)))
? tenantId : null; // null => refuse to call createUser
} Try / catch
try {
usersService.createUser(...);
} catch (ServiceException e) {
if (e.getCode() == Status.TENANT_NOT_EXIST.getCode()) {
// recover: create tenant or pick valid one, then retry once
} else { throw e; }
} Prevention
- Fetch tenant ids dynamically from the tenant list API instead of hard-coding
- Create tenants as part of environment bootstrap before provisioning users
- Re-validate tenantId if the form/session has been open a long time
When it happens
Trigger: POST /users (createUser API) with a tenantId that was deleted, never created, or typed incorrectly; admin UI user form submitted with a stale tenant list; tenant dropped by another admin between loading the form and submitting.
Common situations: Admin deleted a tenant while the user-creation form was open; importing users via API automation with hard-coded tenantIds from another environment; fresh install where no tenants have been created yet.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/1667442f5111df92.
Report an issue: GitHub.