Paginate PR changed files: reviews silently omit files beyond the first 30 #32

Closed
opened 2026-10-10 06:35:48 +01:00 by nimmo · 0 comments
Owner

The review action silently drops changed files after Forgejo's first API page. This caused a false important finding on nixos-config MR #307: the reviewer claimed Vega/phone/router certificates changed without their paired encrypted node-key files, but all three key files are changed in the MR.

Reproduction at MR head 3fe3406f2cb8499d2e39a2485611ce7f78e6a94b:

  1. Read /api/v1/repos/nimmo/nixos-config/pulls/307/files with default pagination: 30 files returned.
  2. Read the same endpoint with ?limit=100&page=1: 33 files returned. The MCP equivalent get_files with per_page: 100 also returns all 33.
  3. The omitted last three files are secrets/nebula/phone.yaml (changed, +3/-3), secrets/nebula/router.yaml (added, +37/-0), and secrets/nebula/vega.yaml (changed, +3/-3). Local git diff --numstat origin/main -- ... independently confirms these changes.
  4. Review of 3fe3406 reports only 30 paths in Diff coverage and treats the three omitted encrypted files as untouched. No omission warning is emitted.

Confirmed source cause: reviewer.py calls api_request(.../pulls/{number}/files) once with no pagination parameters. api_request reads one response. prepare_diff_batches iterates only this returned list, even though the full unified diff contains additional sections, so those files never appear in batch evidence or coverage.

Expected behavior: collect every changed-file page before preparing batches. Use Forgejo page/limit semantics and continue until exhausted (respecting any explicit safety cap with an omission warning). Cross-check the collected count against pr.changed_files; never silently report complete coverage when collection is incomplete. Preserve renamed/binary-file handling and explicit batch-cap omissions.

Acceptance checklist:

  • Multi-page file collection covers >30 and >100 changed files, including server page-size caps.
  • Tests cover empty final pages, API errors on later pages, and mismatched changed_files counts.
  • Every collected changed path receives an explicit coverage status; pagination failures cannot look like a complete review.
  • Regression fixture puts related certificate and key files on opposite pages and confirms both reach review context.
  • Re-review MR #307 after the fix and verify all changed files are accounted for.

Related follow-up-context observation: both reviews on MR #307 are formal COMMENT reviews, but metadata says 'Previous automated review: none found'. The action fetches issue comments only, then human_reply_context immediately returns an empty string when no previous automated comment is found. Thus human responses posted before a push can be omitted from re-review context when formal reviews are enabled. This should be investigated alongside existing #19 or as a separate follow-up; it is distinct from the confirmed changed-file pagination defect.

No private keys, decrypted secrets or credential values are included in this report.

The review action silently drops changed files after Forgejo's first API page. This caused a false important finding on [nixos-config MR #307](https://git.nimmog.uk/nimmo/nixos-config/pulls/307): the reviewer claimed Vega/phone/router certificates changed without their paired encrypted node-key files, but all three key files are changed in the MR. Reproduction at MR head `3fe3406f2cb8499d2e39a2485611ce7f78e6a94b`: 1. Read `/api/v1/repos/nimmo/nixos-config/pulls/307/files` with default pagination: 30 files returned. 2. Read the same endpoint with `?limit=100&page=1`: 33 files returned. The MCP equivalent `get_files` with `per_page: 100` also returns all 33. 3. The omitted last three files are `secrets/nebula/phone.yaml` (changed, +3/-3), `secrets/nebula/router.yaml` (added, +37/-0), and `secrets/nebula/vega.yaml` (changed, +3/-3). Local `git diff --numstat origin/main -- ...` independently confirms these changes. 4. [Review of 3fe3406](https://git.nimmog.uk/nimmo/nixos-config/pulls/307#issuecomment-2935) reports only 30 paths in Diff coverage and treats the three omitted encrypted files as untouched. No omission warning is emitted. Confirmed source cause: [reviewer.py](https://git.nimmog.uk/nimmo/forgejo-auto-pr-review/src/branch/main/reviewer.py#L1051) calls `api_request(.../pulls/{number}/files)` once with no pagination parameters. `api_request` reads one response. `prepare_diff_batches` iterates only this returned list, even though the full unified diff contains additional sections, so those files never appear in batch evidence or coverage. Expected behavior: collect every changed-file page before preparing batches. Use Forgejo `page`/`limit` semantics and continue until exhausted (respecting any explicit safety cap with an omission warning). Cross-check the collected count against `pr.changed_files`; never silently report complete coverage when collection is incomplete. Preserve renamed/binary-file handling and explicit batch-cap omissions. Acceptance checklist: - [ ] Multi-page file collection covers >30 and >100 changed files, including server page-size caps. - [ ] Tests cover empty final pages, API errors on later pages, and mismatched `changed_files` counts. - [ ] Every collected changed path receives an explicit coverage status; pagination failures cannot look like a complete review. - [ ] Regression fixture puts related certificate and key files on opposite pages and confirms both reach review context. - [ ] Re-review MR #307 after the fix and verify all changed files are accounted for. Related follow-up-context observation: both reviews on MR #307 are formal COMMENT reviews, but metadata says 'Previous automated review: none found'. The action fetches issue comments only, then `human_reply_context` immediately returns an empty string when no previous automated comment is found. Thus human responses posted before a push can be omitted from re-review context when formal reviews are enabled. This should be investigated alongside existing #19 or as a separate follow-up; it is distinct from the confirmed changed-file pagination defect. No private keys, decrypted secrets or credential values are included in this report.
nimmo closed this issue 2026-10-10 10:32:48 +01:00
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
nimmo/forgejo-auto-pr-review#32
No description provided.