#3739·pr-agent

Unresolved inline comment positions drop GitHub review findings

Author: strawberry-little-bearCreated Sep 27, 2026Updated Sep 28, 2026
Labelsbug

Bug details

What happened

When PR-Agent cannot map a finding to a line in the current pull-request diff, the finding is silently discarded instead of being posted as a file-level or regular pull-request comment.

In pr_agent/git_providers/github_provider.py, create_inline_comment() calls find_line_number_of_relevant_line_in_file(). If it returns position == -1, the code logs that the position could not be found, sets subject_type = "FILE", and then returns an empty dictionary:

python
if position == -1:
    get_logger().info(f"Could not find position for {relevant_file} {relevant_line_in_file}")
    subject_type = "FILE"
...
return dict(body=body, path=path, position=position) if subject_type == "LINE" else {}

The caller, publish_inline_comment(), immediately passes that value to publish_inline_comments([{}]). The empty payload has no body or path, so it cannot create a useful GitHub comment. In practice, the original finding disappears from the review rather than being surfaced to the user.

This can happen when the model points at an unchanged line, when a line is outside the current patch, when the PR has been updated since the finding was generated, or when the diff-to-line mapping cannot be resolved. These are not unusual conditions for an automated reviewer, so losing the entire finding makes the behavior particularly hard to diagnose.

Minimal reproduction

  1. Run a GitHub review where a finding refers to a file/line that is not present in the current PR diff.
  2. Let find_line_number_of_relevant_line_in_file() return (-1, -1).
  3. Observe that create_inline_comment(body, path, line) returns {}, even though the body and path are still available.
  4. The subsequent publish path receives [{}], and the finding is not posted as either an inline comment or a visible fallback comment.

The current unit test test_create_inline_comment_returns_empty_when_position_unresolved also locks in this empty-payload behavior, which appears to make the data-loss path intentional rather than an explicitly handled fallback.

Expected behavior

If an inline position cannot be resolved, the finding should remain visible. For example, the provider could:

  • preserve the body and path and create a file-level comment when the GitHub API supports it;
  • fall back to a regular pull-request or summary comment containing the file and requested line; or
  • return a structured result that lets the caller handle the unresolved position explicitly, instead of passing an empty dictionary to the publishing path.

It would also be useful to add a regression test that verifies an unresolved position never causes the finding body to be dropped silently.

I may be missing a later fallback elsewhere in the provider, but based on the current call chain the unresolved result is passed forward as an empty payload. Happy to provide a small patch if the maintainers agree on the preferred fallback.