theonedev/onedev · error · NotAcceptableException
'fromLineNumber' must be greater than 0
Error message
'fromLineNumber' must be greater than 0
What it means
Input validation guard in addCodeComment: the AI tool was asked to anchor a code comment at a line below 1. Line numbers are 1-based, so fromLineNumber <= 0 is meaningless and rejected with NotAcceptableException before any file is read. Fix: pass a fromLineNumber >= 1.
Source
Thrown at server-core/src/main/java/io/onedev/server/ai/PullRequestHelper.java:141
return builds;
}
public static List<Map<String, Object>> getComments(PullRequest pullRequest) {
var comments = new ArrayList<Map<String, Object>>();
pullRequest.getComments().stream().sorted(Comparator.comparing(PullRequestComment::getId)).forEach(comment -> {
var commentMap = new HashMap<String, Object>();
commentMap.put("user", comment.getUser().getName());
commentMap.put("date", comment.getDate());
commentMap.put("content", comment.getContent());
comments.add(commentMap);
});
return comments;
}
public static CodeComment addCodeComment(PullRequest pullRequest, User user, String filePath,
int fromLineNumber, int toLineNumber, String commentContent) {
if (fromLineNumber <= 0)
throw new NotAcceptableException("'fromLineNumber' must be greater than 0");
if (fromLineNumber > toLineNumber)
throw new NotAcceptableException("'fromLineNumber' must be less than or equal to 'toLineNumber'");
var project = pullRequest.getProject();
var pullRequestService = OneDev.getInstance(PullRequestService.class);
var gitService = OneDev.getInstance(GitService.class);
var codeCommentService = OneDev.getInstance(CodeCommentService.class);
var oldCommitId = ObjectId.fromString(pullRequest.getBaseCommitHash());
var newCommitId = ObjectId.fromString(pullRequest.getLatestUpdate().getHeadCommitHash());
var comparisonBase = pullRequestService.getComparisonBase(pullRequest, oldCommitId, newCommitId);
var newBlobIdent = new BlobIdent(newCommitId.name(), filePath, FileMode.REGULAR_FILE.getBits());
var lines = project.readLines(newBlobIdent, WhitespaceOption.IGNORE_TRAILING, false);
if (lines == null)
throw new NotFoundException("File not found or not a text file in head commit: " + filePath);
if (toLineNumber > lines.size())
throw new NotAcceptableException("'toLineNumber' must not exceed number of lines in the file");View on GitHub (pinned to d44925c47c)
Solutions
- Set fromLineNumber to a 1-based line number within the file at the pull request head commit.
- Locate the intended line in the diff before calling addCodeComment and pass its actual number.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at server-core/src/main/java/io/onedev/server/ai/PullRequestHelper.java:141 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/08f02aba42ae9baf.
Report an issue: GitHub.