Skip to content

Improve PR Labeler to scale well. - #389

Merged
subham-gp merged 4 commits into
mainfrom
tools/pr-labeler
Sep 19, 2026
Merged

subham-gp merged 4 commits into
mainfrom
tools/pr-labeler

Conversation

@akshitpatel1732

Copy link
Copy Markdown
Contributor

Summary

Improves the PR Labeler by:

  • switching to pagination instead of using the search API to avoid rate limits
  • implementing Per-PR error isolation

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor / code cleanup
  • Documentation
  • CI/CD / infrastructure
  • Security

Affected Components

  • /backend-api
  • /frontend
  • /engine (collectors / policies)
  • /security
  • /infrastructure
  • /.github/workflows
  • /docs

Motivation

The first backfill run for the PR Labeler failed partway because of the Search API's strict rate limits. Although this did not break anything and rerunning the backfill workflow gets the job done, it's better to solve this issue altogether by switching to pagination. Moreover, the workflow failed instead of continuing after the rate-limit reset because any error made the whole job fail.

Testing Done

  • Unit tests pass locally
  • Tested manually — PR Labeler works as intended on a separate test repo with this new implementation.
  • No tests required — explain why:

Security Considerations

No security impact.

Breaking Changes

  • No breaking changes
  • Yes — describe below:

Rollback Plan

  • Revert commit is sufficient
  • Requires additional steps — describe below:

Checklist

  • Code follows project conventions
  • No secrets, credentials, or tokens committed
  • Relevant documentation updated (if applicable)
  • CI/CD workflows pass on this branch
  • PR is focused on one thing

Screenshots

@akshitpatel1732
akshitpatel1732 requested a review from a team as a code owner September 8, 2026 18:37
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Preview Environment

A preview environment can be spun up on demand for this PR.

Action Label Includes
Spin up preview deploy-preview Frontend, backend, database, Redis, OPA, worker
Spin up preview with M365 deploy-preview-m365 Everything above + PowerShell service for Exchange/Teams scan testing
Tear down preview teardown-preview Stops the environment early

The environment will also be torn down automatically when the PR is closed or merged.
Preview URLs will appear in a follow-up comment once the deploy completes (~5–8 min).
M365 scans require real tenant credentials added through the frontend UI.

@github-actions github-actions Bot added github_actions GitHub Actions related area: tools Changes under /tools area: ci-cd Changes under /.github area: multi Touches more than one work area size/S 10-99 lines changed labels Sep 8, 2026
@akshitpatel1732 akshitpatel1732 self-assigned this Sep 8, 2026
@github-actions github-actions Bot added the needs-triage No reviewer has looked at this PR yet label Sep 9, 2026
@subham-gp

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions github-actions Bot removed the needs-triage No reviewer has looked at this PR yet label Sep 13, 2026
@subham-gp

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 14e4c8a703

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/scripts/pr-metadata-labeler.js Outdated

@subham-gp subham-gp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI @akshitpatel1732
Everything looks good to merge once the Codex suggestions are resolved. Could you take a quick look and address those? Thanks!

@github-actions github-actions Bot added the needs-review Author (or someone else) responded since the reviewer's last comment — needs another look label Sep 14, 2026
The previous fix traded one scaling problem for another - solved the backfill's rate-limit crash, but reintroduced the exact same "fetch too much on every call" pattern on the real-time path, which is actually hit far more often (every push/open/reopen on every PR, forever) than a one-off backfill ever is.

Fix: dropped the module-level cache entirely and replaced it with GitHub's server-side creator filter on the Issues API - scopes the query to just the one author being checked (not the whole repo), and stops paginating the instant it's confirmed the answer (as soon as a second PR by that author is seen). This is cheap and correct in both contexts without needing to know or care which caller invoked it - no more real-time-vs-backfill branching logic to reason about, which was really the root of the problem: two callers with very different access patterns sharing one cache that only made sense for one of them.
Comment thread .github/workflows/pr.labels-backfill.yml Fixed
Comment thread .github/workflows/pr.labels-backfill.yml Fixed
@github-actions github-actions Bot added size/M 100-249 lines changed and removed size/S 10-99 lines changed labels Sep 14, 2026
@akshitpatel1732

Copy link
Copy Markdown
Contributor Author

Hi @subham-gp, thanks for the review. I have resolved the issue highlighted by Codex and have also updated my workflows to ensure they are in line with the new Zizmor check.

I have verified that failing workflow checks are stemming from the code beyond the scope of this PR and is solely because of the stale, unrelated code in the branch. This will not affect main when merged.

Could you please have a look at this PR soon? Thanks.

@subham-gp

Copy link
Copy Markdown
Contributor

@codex review

@github-actions github-actions Bot removed the needs-review Author (or someone else) responded since the reviewer's last comment — needs another look label Sep 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eaf72d05fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/scripts/activity-labeler.js
@github-actions github-actions Bot added the needs-review Author (or someone else) responded since the reviewer's last comment — needs another look label Sep 16, 2026
@github-actions github-actions Bot removed the needs-review Author (or someone else) responded since the reviewer's last comment — needs another look label Sep 19, 2026
@subham-gp
subham-gp merged commit e2332b6 into main Sep 19, 2026
15 checks passed
@github-actions
github-actions Bot deleted the tools/pr-labeler branch September 19, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci-cd Changes under /.github area: multi Touches more than one work area area: tools Changes under /tools github_actions GitHub Actions related size/M 100-249 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants