apache/dolphinscheduler · error · IllegalArgumentException
Tenant: [%s] not exists
Error message
Tenant: [%s] not exists
What it means
TenantExistValidator is a javax validation constraint validator used on API request DTOs whose fields carry @TenantExist (or similar). Its validate() looks up the tenant code via tenantDao.queryByCode; if no tenant is present in the database it throws IllegalArgumentException with 'Tenant: [code] not exists'. This ensures API operations referencing a tenant (e.g. user creation, resource upload) target an actual tenant row.
Source
Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/TenantExistValidator.java:43
/**
* This validator is used to validate whether the tenant exists.
* <p> If the tenant does not exist, an {@link IllegalArgumentException} will be thrown. </p>
*/
@Slf4j
@Component
public class TenantExistValidator implements IValidator<String> {
private final TenantDao tenantDao;
public TenantExistValidator(TenantDao tenantDao) {
this.tenantDao = tenantDao;
}
@Override
public void validate(String tenantCode) {
if (!tenantDao.queryByCode(tenantCode).isPresent()) {
throw new IllegalArgumentException(String.format("Tenant: [%s] not exists", tenantCode));
}
}
}
View on GitHub (pinned to 02eac45a1b)
Solutions
- Query the tenants page (or t_ds_tenant) and use the exact existing tenant code in the request.
- Create the missing tenant first via the tenant-management API, then retry the request.
- If the tenant was deleted, clean up or reassign users/resources that reference the stale tenant code.
Example fix
// before
{"user_name":"alice","tenant_code":"prod_tennat"} // typo
// after
{"user_name":"alice","tenant_code":"prod_tenant"} // code exists in t_ds_tenant Defensive patterns
Strategy: validation
Validate before calling
// verify tenant exists before the validated API call
Tenant tenant = tenantMapper.queryByTenantCode(tenantCode);
if (tenant == null) {
throw new IllegalStateException("Tenant not found: " + tenantCode);
} Type guard
function isKnownTenant(code, tenantCodes) {
return typeof code === 'string' && tenantCodes.includes(code);
} Try / catch
try {
// call API with tenantCode
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Tenant:")) {
// list tenants and pick a valid code, or create the tenant first
} else throw e;
} Prevention
- Keep tenant codes in a checked dropdown sourced from the tenants API, not free text
- Clean up or reassign references when deleting tenants
- Verify the API server points at the same DB/cluster where the tenant exists
When it happens
Trigger: Submitting any validated request whose tenantCode field (annotated with the tenant-existence constraint) references a tenant code that has no matching row in t_ds_tenant.
Common situations: Typo in tenant code in API payload or UI config; tenant deleted after a user/config was created referencing it; multi-cluster setups where the API server connects to a DB that lacks the tenant; copying example payloads with placeholder tenant codes.
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/6e2422d3eae89075.
Report an issue: GitHub.