Skip to content

Improve GitHub authentication errors - #24502

Merged
AAraKKe merged 11 commits into
masterfrom
aarakke/friendly-github-auth-errors
Jul 22, 2026
Merged

Improve GitHub authentication errors#24502
AAraKKe merged 11 commits into
masterfrom
aarakke/friendly-github-auth-errors

Conversation

@AAraKKe

@AAraKKe AAraKKe commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds an internal CLI exception-handler registry and uses it to render actionable GitHub authentication and permission errors through ddev's normal styled output. GitHub 401 and non-rate-limit 403 responses now recommend refreshing github.token without interfering with rate-limit retries.

Motivation

Expired or under-permissioned GitHub tokens currently surface low-level HTTP errors, which makes users think ddev itself is broken. This gives them a direct remediation command while preserving existing command context.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

@AAraKKe AAraKKe added the qa/skip-qa Automatically skip this PR for the next QA label Jul 10, 2026
@dd-octo-sts dd-octo-sts Bot added the ddev label Jul 10, 2026
@AAraKKe

AAraKKe commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3694bac61a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +245 to +246
if exc.response.status_code in GITHUB_AUTHENTICATION_STATUS_CODES:
raise GitHubAuthenticationError.from_http_status_error(exc) from exc

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve partial-PR handling after auth conversion

When a side-effectful async call fails with 401/403, this conversion now raises GitHubAuthenticationError, which is not an httpx.HTTPError. Existing call sites such as CreatePullRequestStep.execute still catch (httpx.HTTPError, ValidationError) after self.pr_url is set so they can report “PR created but labeling failed”; with the real client, a label-permission 403 now bypasses that branch and the user loses the created PR URL/manual-label guidance. Update those call sites to catch the new type or otherwise preserve the partial-success handling.

Useful? React with 👍 / 👎.

@AAraKKe AAraKKe Jul 10, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated in bd54df1 after follow-up. GitHubAuthenticationError now bypasses the contextual manual-recovery catches in CreatePullRequestStep and the release branch create/tag workflows, so the centralized CLI handler tells the user to refresh the token. Non-authentication HTTP and validation failures still retain the existing partial-success/manual-recovery guidance. This deliberately treats authentication failures as recoverable configuration errors rather than sending the user directly to a manual workflow.

Comment on lines +333 to +334
if e.response.status_code in GITHUB_AUTHENTICATION_STATUS_CODES:
raise GitHubAuthenticationError.from_http_status_error(e) from e

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid labeling secondary rate limits as auth failures

This now maps every sync-client 403 that is not a primary-limit response (X-RateLimit-Remaining: 0) to a token/permission error. GitHub's REST rate-limit docs (https://docs.github.com/rest/using-the-rest-api/rate-limits-for-the-rest-api#exceeding-the-rate-limit) also describe secondary rate limits as 403/429 responses where retry-after or the error body can be the discriminator, so commands using GitHubManager can tell users to refresh github.token when they should wait/back off instead. Please exclude secondary-limit responses before raising GitHubAuthenticationError.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in f5574ff. Secondary limits are now identified from either Retry-After or GitHub’s secondary-limit response message before authentication conversion. The classifier is shared by the sync and async clients; invalid delays fall back to 60 seconds, and synchronous secondary retries are bounded so persistent limits propagate as HTTPStatusError rather than token guidance.

@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Tests  Code Coverage

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 97.61%
Overall Coverage: 88.45%

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: e3a1660 | Docs | Datadog PR Page | Give us feedback!

@AAraKKe
AAraKKe marked this pull request as ready for review July 21, 2026 15:36
@AAraKKe
AAraKKe requested a review from a team as a code owner July 21, 2026 15:36

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3317a0c6f9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ddev/src/ddev/cli/__init__.py Outdated
steveny91
steveny91 previously approved these changes Jul 21, 2026
@temporal-github-worker-1
temporal-github-worker-1 Bot dismissed steveny91’s stale review July 22, 2026 07:15

Review from steveny91 is dismissed. Related teams and files:

  • agent-integrations
    • ddev/src/ddev/cli/init.py
@dd-octo-sts

dd-octo-sts Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 21 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file
ci Validate CI configuration and code coverage settings
codeowners Validate every integration has a CODEOWNERS entry
config Validate default configuration files against spec.yaml
dep Verify dependency pins are consistent and Agent-compatible
http Validate integrations use the HTTP wrapper correctly
imports Validate check imports do not use deprecated modules
integration-style Validate check code style conventions
jmx-metrics Validate JMX metrics definition files and config
labeler Validate PR labeler config matches integration directories
legacy-signature Validate no integration uses the legacy Agent check signature
license-headers Validate Python files have proper license headers
licenses Validate third-party license attribution list
metadata Validate metadata.csv metric definitions
models Validate configuration data models match spec.yaml
openmetrics Validate OpenMetrics integrations disable the metric limit
package Validate Python package metadata and naming
qa-label Validate the pull request declares whether it needs QA for the next Agent release
readmes Validate README files have required sections
saved-views Validate saved view JSON file structure and fields
version Validate version consistency between package and changelog

View full run

@AAraKKe
AAraKKe enabled auto-merge July 22, 2026 08:29
@AAraKKe
AAraKKe added this pull request to the merge queue Jul 22, 2026
Merged via the queue into master with commit 53f1db3 Jul 22, 2026
369 of 370 checks passed
@AAraKKe
AAraKKe deleted the aarakke/friendly-github-auth-errors branch July 22, 2026 08:34
@dd-octo-sts dd-octo-sts Bot added this to the 7.83.0 milestone Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ddev qa/skip-qa Automatically skip this PR for the next QA team/agent-integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants