Skip to content

fix(github-app): page through repository labels - #13546

Merged
Git-on-my-level merged 4 commits into
BasedHardware:mainfrom
ajanraj:fix/github-app-label-pagination
Sep 14, 2026
Merged

Git-on-my-level merged 4 commits into
BasedHardware:mainfrom
ajanraj:fix/github-app-label-pagination

Conversation

@ajanraj

@ajanraj ajanraj commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

get_repo_labels and get_repo_labels_with_details in plugins/omi-github-app/github_client.py fetch a single page of 100 labels. On repositories with more than 100 labels, the label list silently truncates — ai_select_labels never sees labels beyond page one, and the list_labels chat tool reports an undercounted result.

Both fetchers now follow GitHub's next link headers, mirroring the list_user_repos pagination loop merged in #13184 — including its error semantics: a failure on a later page discards partial results rather than returning a silently truncated list.

Test plan

  • Regression tests in test_github_client.py reuse the existing FakeResponse harness: both fetchers must follow a second page, and a page-2 failure must return []. They fail on the old code (single request, truncated list) and pass after.
  • python test_github_client.py in plugins/omi-github-app: 10 tests pass — the malformed-item cases assert a bad item fails closed to [] instead of raising, and raise KeyError on the pre-fix code.

Could not exercise a live Omi app install (requires OAuth app deployment); the tests drive the production code path through a mocked requests seam, matching the existing suite's approach.

Failure-Class: none

Update: review feedback folded in — the pagination skeleton is now shared (_get_paginated) across all three list fetchers, since duplicated loops are how two of them shipped unpaginated. list_issues was checked and left as-is: its per_page is a deliberate caller-bounded limit, not a full-collection fetch.

Update 2: second review pass folded in — _get_paginated now applies each fetcher's item projection inside its error boundary, so a malformed item on a good page fails closed to [] instead of raising KeyError/TypeError (the pre-refactor contract). The suite is also registered in checks-manifest.yaml (github-app-client-tests, local + ci lanes) so it actually runs in CI; module-level requests/dotenv imports are stubbed like the sibling plugin suites so the file runs on a stdlib-only interpreter.

Closes #13545

Review in cubic

Copilot AI lite review requested due to automatic review settings September 12, 2026 00:11

Copilot AI 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.

🔵 Needs a closer look

Three moderate error-handling issues and one test-count documentation nit remain unresolved.

Pull request overview

This PR adds shared GitHub pagination to prevent repository and label results from being truncated after 100 items.

Changes:

  • Introduces _get_paginated with fail-closed error handling.
  • Updates repository and label fetchers to retrieve all pages.
  • Adds pagination and later-page failure regression tests.
File summaries
File Summary
plugins/omi-github-app/github_client.py Shared pagination and updated fetchers. Moderate (1 vote): three projections moved outside error boundaries, breaking fail-closed behavior for malformed repository or label payloads.
plugins/omi-github-app/test_github_client.py Adds pagination and failure-path tests. Nit (1 vote): reported test count says 7, but 8 test methods are discovered.
Review details

Suppressed comments (4)

plugins/omi-github-app/github_client.py:139

  • The repository-shape conversion is now outside the try/except that previously covered it. If GitHub returns an unexpected item (for example, one missing owner or html_url), this method now raises KeyError instead of preserving its fail-closed [] contract, which can abort repository-loading callers. Keep this projection inside an exception boundary.
        return [
            {
                "name": repo["name"],
                "full_name": repo["full_name"],
                "owner": repo["owner"]["login"],

plugins/omi-github-app/github_client.py:158

  • The label projection moved outside the previous error boundary as part of the pagination refactor. A malformed label item can therefore raise KeyError/TypeError here instead of returning [], changing the method's fail-closed behavior and potentially aborting auto-labeling; keep this conversion inside an exception handler.
        return [label["name"] for label in labels]

plugins/omi-github-app/github_client.py:372

  • As with get_repo_labels, this detail projection is now outside the old try/except. Missing name or color fields in an unexpected API payload will escape as an exception instead of returning [], so the refactor breaks the existing fail-closed contract for this public client method. Keep the projection under the error boundary.
        return [
            {
                "name": label["name"],
                "color": label["color"],
                "description": label.get("description", "")

plugins/omi-github-app/test_github_client.py:82

  • The test plan says python test_github_client.py passes 7 tests, but this file contains 8 discovered test_* methods after the change. Please update the reported count so the verification evidence matches the committed suite.
    def test_get_repo_labels_follows_next_page(self):
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread plugins/omi-github-app/github_client.py Resolved
ajanraj added a commit to ajanraj/omi that referenced this pull request Sep 12, 2026
…undary

Review feedback on BasedHardware#13546: the refactor moved per-item mapping out of
the try/except that used to cover it, so a malformed item in a
successful page escaped as KeyError/TypeError instead of returning [] —
breaking the fetchers' fail-closed contract. _get_paginated now takes a
project callable and applies it inside the boundary, so page failures
and malformed items share one owner.

Tests: malformed-item cases for the dict-building projections assert []
instead of a raised KeyError; both raise on the pre-fix code. uv run
--with requests --with python-dotenv --no-project python
test_github_client.py — 10 tests pass.
@ajanraj

ajanraj commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

Second review pass folded in:

  • All three item projections now run inside _get_paginated's error boundary (d67be34): a malformed item on a successful page fails closed to [] instead of raising KeyError/TypeError, restoring the pre-refactor contract. New malformed-item tests assert the boundary and raise on the pre-fix code.
  • The suite is registered as github-app-client-tests in .github/checks-manifest.yaml (local + ci lanes) so it actually executes in CI; module-level requests/dotenv imports are stubbed during module load like the sibling plugin suites, so the file runs on a stdlib-only interpreter (e68ac71).
  • Test plan count corrected: 10 tests, all passing.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified on the current head — this is a clean fix, and the earlier review feedback is fully resolved.

Per file:

  • plugins/omi-github-app/github_client.py — _get_paginated preserves the fail-closed contract from #13184 and now runs each fetcher's item projection inside the try boundary, so a malformed item on an otherwise good page returns [] instead of raising KeyError/TypeError (this was the open concern from the earlier review; confirmed resolved). get_repo_labels and get_repo_labels_with_details follow next links with explicit page params, so repos with more than 100 labels no longer silently truncate. Leaving list_issues unpaginated is the right call — its per_page is a caller-bounded limit, not a full-collection fetch.
  • plugins/omi-github-app/test_github_client.py — the new tests cover what matters: both label fetchers follow a second page (asserting the exact per_page/page request params), a page-2 failure discards partial results, and malformed items fail closed for repos and detail labels. The module-level requests/dotenv stubs keep the file runnable on a stdlib-only interpreter, matching the sibling plugin suites.
  • .github/checks-manifest.yaml — the github-app-client-tests entry follows the existing format (triggers on plugins/omi-github-app/**, local + ci lanes), so this suite actually executes in CI going forward.

I also ran the suite in an isolated container (no network, no third-party packages): 10/10 pass, and the manifest command (python3 plugins/omi-github-app/test_github_client.py) needs nothing beyond the stdlib.

One non-blocking observation: _get_paginated has no page cap, so a pathological endpoint that always returns a next link would loop indefinitely. This mirrors the already-merged #13184 loop and GitHub's API terminates correctly in practice, so no change requested — just noting it in case a defensive cap is ever wanted.

Nice work — clear test plan and responsive iterations. From my side this is merge-ready pending a human maintainer's sign-off: it's a first contribution and no CI checks have run on this branch yet, so the newly registered manifest check hasn't had a green CI run.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution python labels Sep 12, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Bug fix: get_repo_labels/get_repo_labels_with_details truncated at 100 labels, no pagination. Root cause stated, mirrors existing list_user_repos pagination pattern, tests added, scoped diff. Verified main has no pagination on these fetchers.

ajanraj added a commit to ajanraj/omi that referenced this pull request Sep 12, 2026
…undary

Review feedback on BasedHardware#13546: the refactor moved per-item mapping out of
the try/except that used to cover it, so a malformed item in a
successful page escaped as KeyError/TypeError instead of returning [] —
breaking the fetchers' fail-closed contract. _get_paginated now takes a
project callable and applies it inside the boundary, so page failures
and malformed items share one owner.

Tests: malformed-item cases for the dict-building projections assert []
instead of a raised KeyError; both raise on the pre-fix code. uv run
--with requests --with python-dotenv --no-project python
test_github_client.py — 10 tests pass.
@ajanraj
ajanraj force-pushed the fix/github-app-label-pagination branch from e68ac71 to dbfecd5 Compare September 12, 2026 20:33
@Git-on-my-level

Copy link
Copy Markdown
Member

Reviewed the delta since the previous pass — the branch was rebased, and the plugin changes themselves are unchanged from the already-verified head.

  • .github/checks-manifest.yaml — the new github-app-client-tests entry follows the same shape as its siblings (slack-segments-tests, hey-omi-question-extraction-tests): correct command path, triggers on plugins/omi-github-app/** plus the manifest, local+ci lanes, and an accurate reason for [Bounty proposal] fix(github-app): repo labels truncated at 100 — silent mislabeling #13545. Good call wiring the suite into CI.
  • plugins/omi-github-app/github_client.py / test_github_client.py — byte-identical to the previously reviewed revision (_get_paginated with the fail-closed item projection; no new concerns). Re-ran the suite locally: 10/10 pass.

About the red "Dart Analyze & Tests" check: it is unrelated to this PR. The failures are compile-time ARGUMENT_TYPE_NOT_ASSIGNABLE errors in app/test/providers/deletion_consistency_test.dart and app/test/widgets/chat_content_blocks_test.dart, where test fetcher closures lack the dueStartDate/dueEndDate named parameters that the ActionItemsFetcher typedef (changed in #13570) now requires. This PR touches no Dart files — the rebase inherited the breakage from main, where the mismatch is still present between the current typedef and those test files. A small follow-up on main updating those two call sites should clear the lane for this and other PRs.

No new concerns on this head; leaving the merge call with the approval already on record.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

Both get_repo_labels and get_repo_labels_with_details fetched a single
page of 100 — on repositories with more labels, AI label selection
silently missed every label past the first page and the list-labels
tool undercounted. Same class as the repository-chooser pagination
fix: follow `next` links, and discard partial results on a later-page
error rather than returning a truncated list.

Tests: regression tests assert both fetchers follow a second page and
that a page-2 failure yields [] instead of partial data. All 7 tests
in test_github_client.py pass (`python test_github_client.py`).

Failure-Class: none
Three endpoints now page through `next` links (user repos since
BasedHardware#13184, both label fetchers as of the previous commit) — the
duplicated skeleton is what let two of them ship unpaginated. Extract
_get_paginated so the next list endpoint cannot silently truncate;
callers keep their own transform. Behavior is unchanged: same params,
same discard-partial-results error semantics, pinned by the existing
tests plus a new discard case for the details fetcher.

Tests: 8 tests in test_github_client.py pass.

Failure-Class: none
…undary

Review feedback on BasedHardware#13546: the refactor moved per-item mapping out of
the try/except that used to cover it, so a malformed item in a
successful page escaped as KeyError/TypeError instead of returning [] —
breaking the fetchers' fail-closed contract. _get_paginated now takes a
project callable and applies it inside the boundary, so page failures
and malformed items share one owner.

Tests: malformed-item cases for the dict-building projections assert []
instead of a raised KeyError; both raise on the pre-fix code. uv run
--with requests --with python-dotenv --no-project python
test_github_client.py — 10 tests pass.
The suite ran in no CI lane, so the pagination regression it guards
could have shipped silently again. Stub the module-level requests/dotenv
imports during module load the way the sibling plugin suites do — the
tests patch requests.get per case and perform no real I/O — then
register github-app-client-tests in checks-manifest.yaml (local + ci
lanes).

Verified: python3 plugins/omi-github-app/test_github_client.py — 10
tests pass on a stdlib-only interpreter; python3
.github/scripts/run_checks.py --lane ci --check-id
github-app-client-tests --base origin/main -> PASS; --lane local --list
selects it via plugins/omi-github-app/** on this diff.
@ajanraj
ajanraj force-pushed the fix/github-app-label-pagination branch from dbfecd5 to 1fb9385 Compare September 13, 2026 16:58

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Obvious pagination bug: GitHub labels/repos truncated at 100. _get_paginated follows next links with tests. Admin-squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

positive-signal Automation verified a genuine fix/quality contribution python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bounty proposal] fix(github-app): repo labels truncated at 100 — silent mislabeling

4 participants