Fix pagination bug in auto-publish-pr.yaml listFiles() call

Open Beginner friendly
#3,670 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
90/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
github-actions, javascript
Domain
ci-cd, devops

Research direction

Start in .github/workflows/auto-publish-pr.yaml at the detect-changes step around line 182, and inspect the pulls.listFiles() call plus the checks around lines 189-190. Update the workflow to handle all changed files, then run /publish on a PR with more than 30 changed files. Done means non-metadata changes trigger the OCI build and the skip message appears only for metadata-only changes.

Written by the indexing model from the issue text.

Description

bug github_actions ready-for-triage triaged

What happened

PR #3644 updated the backstage workspace (36 files changed). The /publish workflow's detect-changes step at line 182 of auto-publish-pr.yaml calls github.rest.pulls.listFiles() without pagination or a per_page parameter. GitHub's REST API returns at most 30 items per page by default. Since this PR had 36 files — and the 34 metadata/*.yaml files sort alphabetically before plugins-list.yaml and source.json — the two non-metadata files landed on page 2 and were never fetched. The step concluded "only metadata files changed" and skipped the OCI build entirely. Without pr_3644__* OCI images, all 13 E2E tests failed. Maintainers ran /publish 5+ times over ~18 hours before the CI diagnosis agent identified the root cause. The PR was ultimately merged with failing checks, relying on the diagnosis that the failure was a pre-existing infrastructure bug.

What could go better

The listFiles() call should paginate to handle PRs with more than 30 files. This is a latent bug that has likely existed since the workflow was written but only surfaced now because the backstage workspace update exceeded 30 files. Any workspace update touching 31+ files (metadata + source files) will silently skip the OCI build. The CI diagnosis agent (comment) independently confirmed this diagnosis with high confidence, citing the specific line number and explaining the alphabetical sort order that causes plugins-list.yaml and source.json to be on the truncated page. Confidence: high — the bug is confirmed by code inspection, the CI diagnosis agent's analysis, and the observed behavior ("build skipped" message on a PR that clearly changed non-metadata files).

Proposed change

In .github/workflows/auto-publish-pr.yaml, replace the unpaginated listFiles() call (line 182) with GitHub's pagination helper:

Before:

const prFiles = await github.rest.pulls.listFiles({
  owner: context.repo.owner,
  repo: context.repo.repo,
  pull_number: prNumber,
});

After:

const prFiles = await github.paginate(github.rest.pulls.listFiles, {
  owner: context.repo.owner,
  repo: context.repo.repo,
  pull_number: prNumber,
  per_page: 100,
});

Also update the references on lines 189-190 from prFiles.data.length / prFiles.data.every(...) to prFiles.length / prFiles.every(...), since github.paginate() returns the array directly rather than wrapping it in a .data property.

Validation criteria

  1. After the fix, run /publish on a PR with >30 changed files (e.g., a backstage workspace update). The workflow should detect non-metadata files and proceed with the OCI build instead of skipping it.
  2. The "build skipped (only metadata files changed)" message should only appear on PRs that genuinely only modify metadata/*.yaml files.
  3. The next 3 workspace updates that touch >30 files should complete /publish successfully on the first attempt without the pagination-related skip.

Generated by retro agent from https://github.com/redhat-developer/rhdh-plugin-export-overlays/pull/3644

Dominant language
TypeScript
Stars
9
Forks
72
Avg merge
3d 9h
Merged PRs (30d)
133

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from redhat-developer/rhdh-plugin-export-overlays

All issues in redhat-developer/rhdh-plugin-export-overlays

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.