apache/dolphinscheduler · error · ServiceException

10017

10017

Error message

tenant [{tenantCode}] not exists

What it means

Status.TENANT_NOT_EXIST from updateTenantValid: the tenant record being updated (existsTenant) is null — the tenant id supplied to updateTenant does not correspond to any existing tenant. Updates operate on an already-loaded tenant; without it the operation cannot proceed.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java:108

            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 parameters
        else if (StringUtils.isEmpty(updateTenant.getTenantCode())) {
            throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR, updateTenant.getTenantCode());
        } else if (StringUtils.length(updateTenant.getTenantCode()) > TENANT_FULL_NAME_MAX_LENGTH) {
            throw new ServiceException(Status.TENANT_FULL_NAME_TOO_LONG_ERROR);
        } else if (!RegexUtils.isValidLinuxUserName(updateTenant.getTenantCode())) {
            throw new ServiceException(Status.CHECK_OS_TENANT_CODE_ERROR);
        } else if (!Objects.equals(existsTenant.getTenantCode(), updateTenant.getTenantCode())
                && checkTenantExists(updateTenant.getTenantCode())) {
            throw new ServiceException(Status.OS_TENANT_CODE_EXIST, updateTenant.getTenantCode());
        }
    }

    /**
     * create tenant
     *
     * @param loginUser login user

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Verify the tenant id via GET /tenants list and use a current id.
  2. Refresh the UI page to drop stale tenant references.
  3. Recreate the missing tenant if it was deleted unintentionally, then update.
  4. Fix environment sync so tenants exist in the target instance before running update scripts.

Example fix

// before
int id = 42; // cached from last week
tenantService.updateTenant(loginUser, id, "newcode", "desc", 1, 1);
// after
Integer id = tenantList.stream().filter(t -> t.getTenantCode().equals("oldcode")).findFirst()
        .map(Tenant::getId).orElse(null);
if (id != null) tenantService.updateTenant(loginUser, id, "newcode", "desc", 1, 1);
Defensive patterns

Strategy: validation

Validate before calling

boolean tenantExists = tenantService.listAllTenants(loginUser).stream()
        .anyMatch(t -> t.getId() == tenantId);
if (!tenantExists) {
    throw new IllegalArgumentException("tenant id " + tenantId + " does not exist; refresh from tenant list");
}

Try / catch

try {
    tenantService.updateTenant(loginUser, tenantId, code, desc, queueId, 1);
} catch (ServiceException e) {
    if (e.getCode() == 10017) { /* stale id: re-query tenant list and retry with current id */ }
}

Prevention

When it happens

Trigger: PUT /tenants/{id} with an id that was deleted, never existed, or belongs to another environment; stale UI page holding a tenant deleted in another tab.

Common situations: Scripts caching tenant ids across cleanup jobs; environments cloned without the tenants table contents; users editing a tenant deleted by an admin concurrently.

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/0fc7513ad7318564. Report an issue: GitHub.