{"record":{"id":"b163932db34608d6","repo":"apache/dolphinscheduler","slug":"skiplinenum-must-be-greater-than-or-equal-to-0","errorCode":null,"errorMessage":"skipLineNum must be greater than or equal to 0","messagePattern":"skipLineNum must be greater than or equal to 0","errorType":"validation","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/resource/FetchFileContentDtoValidator.java","lineNumber":38,"sourceCode":"import org.apache.dolphinscheduler.api.dto.resources.FetchFileContentDto;\nimport org.apache.dolphinscheduler.api.exceptions.ServiceException;\nimport org.apache.dolphinscheduler.dao.entity.User;\nimport org.apache.dolphinscheduler.dao.repository.TenantDao;\nimport org.apache.dolphinscheduler.plugin.storage.api.StorageOperator;\n\nimport org.springframework.stereotype.Component;\n\n@Component\npublic class FetchFileContentDtoValidator extends AbstractResourceValidator<FetchFileContentDto> {\n\n    public FetchFileContentDtoValidator(StorageOperator storageOperator, TenantDao tenantDao) {\n        super(storageOperator, tenantDao);\n    }\n\n    @Override\n    public void validate(FetchFileContentDto fetchFileContentDto) {\n        if (fetchFileContentDto.getSkipLineNum() < 0) {\n            throw new ServiceException(\"skipLineNum must be greater than or equal to 0\");\n        }\n        if (fetchFileContentDto.getLimit() != -1 && fetchFileContentDto.getLimit() <= 0) {\n            throw new ServiceException(\"limit must be -1 or greater than 0\");\n        }\n        String resourceFileAbsolutePath = fetchFileContentDto.getResourceFileAbsolutePath();\n        User loginUser = fetchFileContentDto.getLoginUser();\n\n        exceptionResourceAbsolutePathInvalidated(resourceFileAbsolutePath);\n        exceptionResourceIsNotFile(resourceFileAbsolutePath);\n        exceptionUserNoResourcePermission(loginUser, resourceFileAbsolutePath);\n        exceptionFileContentCannotFetch(resourceFileAbsolutePath);\n    }\n}\n","sourceCodeStart":20,"sourceCodeEnd":52,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/validator/resource/FetchFileContentDtoValidator.java#L20-L52","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass 0 to read from the beginning of the file; use -1 only for limit to mean 'read all'.","Clamp computed pagination offsets with Math.max(0, offset) in the client.","Fix the UI/component that computes skipLineNum to never emit negatives."],"exampleFix":"// before\nint skipLineNum = (page - 1) * pageSize; // page=0 -> -pageSize\n// after\nint skipLineNum = Math.max(0, (page - 1) * pageSize);","handlingStrategy":"validation","validationCode":"if (skipLineNum < 0) { throw new IllegalArgumentException(\"skipLineNum must be >= 0\"); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 0 (not -1) to read from the file start.","Clamp pagination offsets with Math.max(0, offset).","Validate request parameters client-side before calling the API."],"tags":["validation","pagination","resource","dolphinscheduler"],"backgroundTag":"value-out-of-range","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}