theonedev/onedev · error · NotAcceptableException
Cannot add code comment outside of diff
Error message
Cannot add code comment outside of diff
What it means
Generic guard in addCodeComment rejecting any attempt to anchor a code comment on a path not part of the pull request diff. It fires from the change-matching logic when filePath has no corresponding BlobChange, so the comment has no diff context.
Source
Thrown at server-core/src/main/java/io/onedev/server/ai/PullRequestHelper.java:189
var changeType = matchingEntry.getChangeType();
if (changeType == ChangeType.RENAME && matchingEntry.getOldPath().equals(matchingEntry.getNewPath()))
changeType = ChangeType.MODIFY;
var oldDiffBlobIdent = GitUtils.getOldBlobIdent(matchingEntry, comparisonBase.name());
var newDiffBlobIdent = GitUtils.getNewBlobIdent(matchingEntry, newCommitId.name());
var blobChange = new BlobChange(changeType, oldDiffBlobIdent, newDiffBlobIdent, WhitespaceOption.IGNORE_TRAILING) {
private static final long serialVersionUID = 1L;
@Override
public Project getProject() {
return project;
}
};
var range = new PlanarRange(fromLineNumber - 1, 0, toLineNumber - 1, lines.get(toLineNumber - 1).length());
if (!blobChange.isVisible(new DiffPlanarRange(false, range)))
throw new NotAcceptableException("Cannot add code comment outside of diff");
var comment = new CodeComment();
comment.setProject(project);
comment.setUser(user);
comment.setContent(commentContent);
var mark = new Mark();
mark.setCommitHash(newCommitId.name());
mark.setPath(filePath);
mark.setRange(range);
comment.setMark(mark);
var compareContext = new CompareContext();
compareContext.setPullRequest(pullRequest);
compareContext.setOldCommitHash(oldCommitId.name());
compareContext.setNewCommitHash(newCommitId.name());
compareContext.setPathFilter(filePath);
comment.setCompareContext(compareContext);View on GitHub (pinned to d44925c47c)
Solutions
- Restrict comments to files appearing in the pull request diff.
- Use an issue or regular PR comment for files outside the diff.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at server-core/src/main/java/io/onedev/server/ai/PullRequestHelper.java:189 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/bd5bdec2d6df1b7f.
Report an issue: GitHub.