apache/dolphinscheduler · error · ServiceException

REQUEST_PARAMS_NOT_VALID_ERROR

REQUEST_PARAMS_NOT_VALID_ERROR

Error message

REQUEST_PARAMS_NOT_VALID_ERROR

What it means

createToken validates inputs before minting an access token; when userId is <= 0 it throws ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR) with a message that the user id must be greater than 0. This guards against creating tokens bound to an invalid or absent user.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java:115

    /**
     * create token
     *
     * @param loginUser loginUser
     * @param userId token for user
     * @param expireTime token expire time
     * @param token token string (if it is absent, it will be automatically generated)
     * @return create result code
     */
    @SuppressWarnings("checkstyle:WhitespaceAround")
    @Override
    public AccessToken createToken(User loginUser, int userId, String expireTime, String token) {

        // 1. check permission
        checkAccessTokenTargetUserIsLoginUserOrAdmin(loginUser, userId);

        // 2. check if user is existed
        if (userId <= 0) {
            throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR,
                    "User id: " + userId + " should not less than or equals to 0.");
        }

        // 3. generate access token if absent
        if (StringUtils.isBlank(token)) {
            token = EncryptionUtils.getMd5(userId + expireTime + System.currentTimeMillis());
        }

        // 4. persist to the database
        AccessToken accessToken = new AccessToken();
        accessToken.setUserId(userId);
        accessToken.setExpireTime(DateUtils.stringToDate(expireTime));
        accessToken.setToken(token);
        accessToken.setCreateTime(new Date());
        accessToken.setUpdateTime(new Date());

        int insert = accessTokenDao.insert(accessToken);

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Pass the id of an existing user (> 0) in the create-token request; look it up via the users API if unknown.
  2. Fix the client form/script so userId is populated before submitting (require field selection).
  3. If the value comes from config, verify the configured user id actually exists and is not 0/-1 placeholder.
  4. Validate the payload client-side before calling the API.

Example fix

// before: empty form field bound to 0
{"userId": 0, "expireTime": "2026-01-01"}

// after: real user id
{"userId": 42, "expireTime": "2026-01-01"}
Defensive patterns

Strategy: validation

Validate before calling

// validate payload before the API call
if (userId == null || userId <= 0) {
    throw new IllegalArgumentException("userId must be a positive existing user id");
}

Type guard

boolean validUserId(Integer userId) { return userId != null && userId > 0; }

Try / catch

try {
    accessTokenService.createToken(loginUser, userId, expireTime, token);
} catch (ServiceException e) {
    if (e.getCode() == Status.REQUEST_PARAMS_NOT_VALID_ERROR) {
        throw new IllegalArgumentException("Provide a valid userId > 0", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling createToken (POST /access-tokens) with userId 0, negative, or null-coerced-to-0 — typically when the caller omitted the userId field, the form sent an empty string, or the wrong variable was bound.

Common situations: API clients omitting userId in the request body so it defaults to 0; UI forms not populating the user dropdown before submit; scripts passing the token's own id instead of a user id; property binding of "" to int yielding 0.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/1872b7df042d2ed6. Report an issue: GitHub.