Repository navigation
EPMDEDP-17383: fix: list the token user's private GitHub repositories - #96
Merged
Merged
Conversation
The organization dropdown offers the token user's own login as an owner.
For that owner, listRepositories fell back to GET /users/{owner}/repos,
which returns public repositories only, so private repositories were
missing from the repository picker and from the create-mode name check.
When the owner is the token user (case-insensitive), list
GET /user/repos with affiliation=owner instead. Other users keep the
public listing. A 401 or 403 on GET /user, as returned for a GitHub App
installation token, also keeps the public listing; any other lookup
error fails the list.
Signed-off-by: Sergiy Kulanov <sergiy_kulanov@epam.com>
Collaborator
Pipeline
|
| Status | Task | Duration |
|---|---|---|
| ✓ Passed | github-set-pending-status | 7s |
| ✓ Passed | fetch-repository | 17s |
| ✓ Passed | init-values | 6s |
| ✓ Passed | get-cache | 59s |
| ✓ Passed | commit-validate | 6s |
| ✓ Passed | dockerfile-lint | 6s |
| ✓ Passed | helm-lint | 7s |
| ✓ Passed | helm-docs | 7s |
| ✓ Passed | build | 1m4s |
| ✓ Passed | sonar | 26s |
| ✓ Passed | buildkit-verify | 16s |
| ✓ Passed | save-cache | 1m9s |
| ✓ Passed | github-report-pipeline-status | 6s |
Pushing new commits re-runs this pipeline automatically.
To re-run it without new commits, comment/recheck.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
listRepositories(owner) GET /orgs/{owner} → organization: GET /orgs/{owner}/repos (unchanged) 404 → user owner - GET /users/{owner}/repos # public only, also for the token user + GET /user # token login + 401 / 403 → login unknown + other error → fail: "failed to get current user" + owner == login (case-insensitive) + GET /user/repos?affiliation=owner # private included + else + GET /users/{owner}/reposThe organization picker offers the token user's own login as an owner. For that owner, private repositories were missing from the Repository picker and from the create-mode "already exists" check, so a name clash surfaced later in codebase-operator.
affiliation=owner: the default affiliation adds collaborator and organization member repositories, which belong to other owners.GET /user(GitHub App installation token) keeps the public listing; a rejected token still fails onGET /users/{owner}/repos.Evidence
Live GitHub, classic PAT with
reposcope, owner = token login (first page, 100 repositories):GET /users/{login}/repos(before)GET /user/repos?affiliation=owner(after)Tests (
ListRepositoriesagainsthttptest, requests recorded):TestGitHubProviderListRepositoriesForUserrowstoken userandtoken user in another letter casefail: the provider requests/users/jdoe/repos.After:
/user,/user/repos?affiliation=owner&per_page=100, page 2; the private repository is returned.other userand 401 / 403 onGET /user:/user, then/users/octocat/repos; result unchanged.TestGitHubProviderListRepositoriesErrors: 404 / 500 onGET /userfail withfailed to get current user; failures on/users/{owner}/reposand/user/reposkeep their classification (404, 502, 500).Not testbed-verified: the testbed runs GitLab only.
Merge Danger
Door: two-way
Blast Radius: GitHub user owners
GET /userper user-owner listing, on cache miss only.GET /userfailure other than 401 / 403 now fails another user's listing instead of returning its public repositories.