apache/dolphinscheduler · error · ServiceException

skipLineNum must be greater than or equal to 0

Error message

skipLineNum must be greater than or equal to 0

What it means

FetchFileContentDtoValidator.validate throws this ServiceException when the skipLineNum parameter of a fetch-file-content request is negative. skipLineNum offsets into the file's lines and must be >= 0.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/resource/FetchFileContentDtoValidator.java:38

import org.apache.dolphinscheduler.api.dto.resources.FetchFileContentDto;
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.repository.TenantDao;
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;

import org.springframework.stereotype.Component;

@Component
public class FetchFileContentDtoValidator extends AbstractResourceValidator<FetchFileContentDto> {

    public FetchFileContentDtoValidator(StorageOperator storageOperator, TenantDao tenantDao) {
        super(storageOperator, tenantDao);
    }

    @Override
    public void validate(FetchFileContentDto fetchFileContentDto) {
        if (fetchFileContentDto.getSkipLineNum() < 0) {
            throw new ServiceException("skipLineNum must be greater than or equal to 0");
        }
        if (fetchFileContentDto.getLimit() != -1 && fetchFileContentDto.getLimit() <= 0) {
            throw new ServiceException("limit must be -1 or greater than 0");
        }
        String resourceFileAbsolutePath = fetchFileContentDto.getResourceFileAbsolutePath();
        User loginUser = fetchFileContentDto.getLoginUser();

        exceptionResourceAbsolutePathInvalidated(resourceFileAbsolutePath);
        exceptionResourceIsNotFile(resourceFileAbsolutePath);
        exceptionUserNoResourcePermission(loginUser, resourceFileAbsolutePath);
        exceptionFileContentCannotFetch(resourceFileAbsolutePath);
    }
}

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Pass 0 to read from the beginning of the file; use -1 only for limit to mean 'read all'.
  2. Clamp computed pagination offsets with Math.max(0, offset) in the client.
  3. Fix the UI/component that computes skipLineNum to never emit negatives.

Example fix

// before
int skipLineNum = (page - 1) * pageSize; // page=0 -> -pageSize
// after
int skipLineNum = Math.max(0, (page - 1) * pageSize);
Defensive patterns

Strategy: validation

Validate before calling

if (skipLineNum < 0) { throw new IllegalArgumentException("skipLineNum must be >= 0"); }

Prevention

When it happens

Trigger: Calling the view/read-file-content API (or its REST endpoint) with skipLineNum < 0, e.g. -1 used in place of 'no skip' instead of 0.

Common situations: Client code using -1 as a sentinel for 'from the beginning'; UI pagination math producing negative offsets on the first page; hand-built REST calls.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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