Skip to content

Don't require GitHub auth for public-repo PR status/label reads (#16210)#16292

Open
helen229 wants to merge 10 commits into
mainfrom
fix/16210-github-auth-optional-public-reads
Open

Don't require GitHub auth for public-repo PR status/label reads (#16210)#16292
helen229 wants to merge 10 commits into
mainfrom
fix/16210-github-auth-optional-public-reads

Conversation

@helen229

@helen229 helen229 commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #16210.

SDK generation (and other release-plan operations) prompted users to authenticate with GitHub (gh auth login) even when the only thing being read was the status, checks, and labels of a public spec pull request. For a PR in the public azure-rest-api-specs repository this information is available anonymously, so requiring authentication was unnecessary and confusing.

Changes

  • Added an anonymous GitHub client and a small ReadWithAnonymousFallbackAsync helper in GitConnection. Read-only operations are attempted anonymously first; only if GitHub signals that authentication is required (any Octokit.ApiException — private repo/404, forbidden/403, unauthorized/401, or rate limit) do they retry with an authenticated client, which prompts for gh auth login when no token is available.
  • Switched the read-only public-PR operations (GetPullRequestAsync, GetPullRequestHeadSha, and the check-runs lookup in GetPullRequestChecksAsync) to use the helper.
  • Added GitHubServiceTests covering: anonymous success (no auth attempted), retry-authenticated when anonymous is denied, and surfacing the auth prompt when no token is available.
  • CHANGELOG entry under 0.6.25 Bugs Fixed.

Testing

dotnet test --filter "FullyQualifiedName~GitHubServiceTests|FullyQualifiedName~SpecWorkFlowToolTests" — all passing.

@github-actions github-actions Bot added the azsdk-cli Issues related to Azure/azure-sdk-tools::tools/azsdk-cli label Jul 7, 2026
@helen229 helen229 marked this pull request as ready for review July 7, 2026 21:32
@helen229 helen229 requested a review from a team as a code owner July 7, 2026 21:32
Copilot AI review requested due to automatic review settings July 7, 2026 21:32

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.

Pull request overview

This PR updates the azsdk CLI’s GitHub access layer to avoid prompting users to authenticate (gh auth login) when performing read-only lookups against public repositories (notably public azure-rest-api-specs PRs during SDK generation). It introduces an anonymous-first read pattern with authenticated fallback and adds tests + a changelog entry to document the behavior change.

Changes:

  • Added an unauthenticated GitHubClient plus a ReadWithAnonymousFallbackAsync helper to try public reads anonymously before falling back to authenticated access.
  • Updated public read paths (GetPullRequestAsync, GetPullRequestHeadSha, check-runs lookup in GetPullRequestChecksAsync) to use anonymous-first behavior.
  • Added GitHubServiceTests and documented the fix in the CLI changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
tools/azsdk-cli/Azure.Sdk.Tools.Cli/Services/GitHubService.cs Adds anonymous client + helper and routes key public PR read operations through anonymous-first access.
tools/azsdk-cli/Azure.Sdk.Tools.Cli/CHANGELOG.md Documents the behavior change under 0.6.25 bug fixes.
tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Services/GitHubServiceTests.cs Adds coverage for anonymous success, authenticated retry, and auth prompting when no token is available.

Comment thread tools/azsdk-cli/Azure.Sdk.Tools.Cli/Services/GitHubService.cs
Comment thread tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Services/GitHubServiceTests.cs Outdated
Comment thread tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Services/GitHubServiceTests.cs Outdated
Comment thread tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Services/GitHubServiceTests.cs Outdated
helen229 and others added 5 commits July 7, 2026 14:36
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment thread tools/azsdk-cli/Azure.Sdk.Tools.Cli/Services/GitHubService.cs Outdated
@helen229 helen229 enabled auto-merge (squash) July 8, 2026 19:59
…vice.cs

Co-authored-by: helen229 <19517014+helen229@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azsdk-cli Issues related to Azure/azure-sdk-tools::tools/azsdk-cli

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Release plan and agent usage stabilization: GitHub authentication

4 participants