Skip to content

Fix listing installation repositories with user authentication - #3571

Merged
EnricoMi merged 9 commits into
PyGithub:mainfrom
hansu650:fix/user-installation-repos
Nov 17, 2026
Merged

EnricoMi merged 9 commits into
PyGithub:mainfrom
hansu650:fix/user-installation-repos

Conversation

@hansu650

@hansu650 hansu650 commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3546.

Installation.get_repos() always calls /installation/repositories, which requires installation authentication. An installation obtained through Github(auth=AppUserAuth(...)).get_user().get_installations() instead needs /user/installations/{installation_id}/repositories.

Select that endpoint when the requester uses AppUserAuth. Other authentication types retain the installation endpoint, including the existing AppAuth to AppInstallationAuth conversion. The API-provided repositories_url attribute remains unchanged; an opaque Auth.Token keeps its existing behavior.

Three offline replay cases cover GitHub.com and an Enterprise-style base URL with a non-default port, two-page iteration, totalCount, authentication preservation, and an empty installation-token result. These are synthetic fixtures with placeholder credentials, not new live API recordings.

Validation — 2026-11-13

Head c55c9ded merges upstream 33fdcf50. The merge retains upstream's VCR-based request capture; the installation-token assertion now checks the original placeholder token seen by that capture layer.

Dedicated Windows / CPython 3.13.15 environment:

  • Full configured pytest suite: 1,144 passed, 1 skipped, 664 subtests passed. The skip is the existing Windows asset-download case; 14 deprecation warnings were reported.
  • Installation module: 7 passed.
  • Repository-wide pre-commit hooks: passed.
  • Mypy: passed, 323 source files.
  • git diff --check: passed.

The original submission's baseline run had two user-authentication failures and five passes without the endpoint fix. That earlier baseline and its build/documentation checks were not repeated for this merge. Live GitHub App authentication, other platforms/Python versions and the separate OpenAPI CLI suite were not run locally. Current remote CI is tracked separately.

AI assistance: prepared and validated with OpenAI Codex.

hansu650 and others added 6 commits September 6, 2026 20:14
Use the user-scoped endpoint for AppUserAuth while preserving installation-token behavior, lazy pagination, and requester settings. Add offline HTTP regression coverage for GitHub.com and custom API URLs.

Assisted-by: OpenAI Codex
…tion-repos' into copilot/hansu650fixuser-installation-repos

# Conflicts:
#	tests/Installation.py

Co-authored-by: EnricoMi <[email protected]>
@EnricoMi

Copy link
Copy Markdown
Collaborator

@hansu650 please consider merging hansu650#1 into your branch.

@hansu650

Copy link
Copy Markdown
Contributor Author

Thanks @EnricoMi — I merged hansu650#1 into this branch, preserving your commits, and fixed the import-group spacing flagged by Ruff.

The tests now use Framework.BasicTestCase, captureRequests, and the three replay fixtures for github.com, GitHub Enterprise, and installation-token authentication.

Local validation (Windows, Python 3.13.15):

  • pytest tests/Installation.py: 7 passed.
  • Full test suite: 1,132 passed, 1 existing Windows skip, and 649 subtests passed.
  • Ruff, Black, and mypy passed.

The test runs also emitted existing deprecation warnings and a local pytest-cache permission warning; neither affected the test results. CI for the updated head still needs to run.

@EnricoMi EnricoMi 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.

Thanks for the fix, please adjust the test file.

Comment thread tests/Installation.py Resolved
@EnricoMi EnricoMi changed the title fix: list installation repositories with user authentication Fix listing installation repositories with user authentication Nov 13, 2026
@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.04%. Comparing base (7de2644) to head (5761a84).
⚠️ Report is 82 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3571      +/-   ##
==========================================
+ Coverage   97.00%   97.04%   +0.04%     
==========================================
  Files         172      180       +8     
  Lines       18934    20445    +1511     
==========================================
+ Hits        18366    19841    +1475     
- Misses        568      604      +36     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Test Results

     9 files  ± 0       9 suites  ±0   7m 9s ⏱️ -51s
 1 179 tests +12   1 179 ✅ +12  0 💤 ±0  0 ❌ ±0 
14 569 runs  +96  14 568 ✅ +96  1 💤 ±0  0 ❌ ±0 

Results for commit 5761a84. ± Comparison against base commit 33fdcf5.

♻️ This comment has been updated with latest results.

@EnricoMi EnricoMi 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.

LGTM!

@EnricoMi
EnricoMi enabled auto-merge November 17, 2026 09:22
@EnricoMi
EnricoMi added this pull request to the merge queue Nov 17, 2026
Merged via the queue into PyGithub:main with commit d48832d Nov 17, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Installation.get_repos needs to differentiate between IAT access and UAT access

3 participants