Repository navigation
fix(github-app): page through repository labels - #13546
Conversation
There was a problem hiding this comment.
🔵 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_paginatedwith 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/exceptthat previously covered it. If GitHub returns an unexpected item (for example, one missingownerorhtml_url), this method now raisesKeyErrorinstead 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/TypeErrorhere 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 oldtry/except. Missingnameorcolorfields 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.pypasses 7 tests, but this file contains 8 discoveredtest_*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.
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…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.
|
Second review pass folded in:
|
Git-on-my-level
left a comment
There was a problem hiding this comment.
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_paginatedpreserves the fail-closed contract from #13184 and now runs each fetcher's item projection inside thetryboundary, so a malformed item on an otherwise good page returns[]instead of raisingKeyError/TypeError(this was the open concern from the earlier review; confirmed resolved).get_repo_labelsandget_repo_labels_with_detailsfollownextlinks with explicitpageparams, so repos with more than 100 labels no longer silently truncate. Leavinglist_issuesunpaginated is the right call — itsper_pageis 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 exactper_page/pagerequest params), a page-2 failure discards partial results, and malformed items fail closed for repos and detail labels. The module-levelrequests/dotenvstubs keep the file runnable on a stdlib-only interpreter, matching the sibling plugin suites..github/checks-manifest.yaml— thegithub-app-client-testsentry follows the existing format (triggers onplugins/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.
kodjima33
left a comment
There was a problem hiding this comment.
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.
…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.
e68ac71 to
dbfecd5
Compare
|
Reviewed the delta since the previous pass — the branch was rebased, and the plugin changes themselves are unchanged from the already-verified head.
About the red "Dart Analyze & Tests" check: it is unrelated to this PR. The failures are compile-time 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 |
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.
dbfecd5 to
1fb9385
Compare
Git-on-my-level
left a comment
There was a problem hiding this comment.
Obvious pagination bug: GitHub labels/repos truncated at 100. _get_paginated follows next links with tests. Admin-squash.
Summary
get_repo_labelsandget_repo_labels_with_detailsinplugins/omi-github-app/github_client.pyfetch a single page of 100 labels. On repositories with more than 100 labels, the label list silently truncates —ai_select_labelsnever sees labels beyond page one, and thelist_labelschat tool reports an undercounted result.Both fetchers now follow GitHub's
nextlink headers, mirroring thelist_user_repospagination 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
test_github_client.pyreuse the existingFakeResponseharness: 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.pyinplugins/omi-github-app: 10 tests pass — the malformed-item cases assert a bad item fails closed to[]instead of raising, and raiseKeyErroron 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
requestsseam, 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_issueswas checked and left as-is: itsper_pageis a deliberate caller-bounded limit, not a full-collection fetch.Update 2: second review pass folded in —
_get_paginatednow applies each fetcher's item projection inside its error boundary, so a malformed item on a good page fails closed to[]instead of raisingKeyError/TypeError(the pre-refactor contract). The suite is also registered inchecks-manifest.yaml(github-app-client-tests, local + ci lanes) so it actually runs in CI; module-levelrequests/dotenvimports are stubbed like the sibling plugin suites so the file runs on a stdlib-only interpreter.Closes #13545