Skip to content

Comments

Distinguish Copilot licensing errors from GitHub App permission errors#108565

Merged
JoshFerge merged 5 commits intomasterfrom
claude/debug-copilot-403-error-eUY9I
Feb 20, 2026
Merged

Distinguish Copilot licensing errors from GitHub App permission errors#108565
JoshFerge merged 5 commits intomasterfrom
claude/debug-copilot-403-error-eUY9I

Conversation

@JoshFerge
Copy link
Member

Description

This PR improves error handling for GitHub Copilot integration failures by distinguishing between two different types of 403 errors:

  1. Copilot licensing errors: When a user's GitHub account lacks an active Copilot subscription, return failure_type: "generic" with a user-friendly message about the missing license.
  2. GitHub App permission errors: When the Sentry GitHub App lacks required permissions, return failure_type: "github_app_permissions" to trigger the permissions modal.

Previously, all 403 errors were treated as permission issues, which could confuse users whose actual problem was a missing Copilot license rather than app permissions.

Changes

  • src/sentry/seer/autofix/coding_agent.py: Added logic to check the error message for "not licensed" text when handling 403 responses. If found, treat it as a generic licensing error; otherwise, treat it as a GitHub App permissions issue.
  • tests/sentry/integrations/api/endpoints/test_organization_coding_agents.py: Added test case test_copilot_not_licensed_403_returns_generic_failure_type to verify that licensing-related 403 errors return the correct failure type and error message.

Test Plan

The new test case verifies that:

  • A 403 response with "not licensed to use Copilot" in the error message returns failure_type: "generic"
  • The error message mentions the Copilot license issue
  • The response indicates success with appropriate failure details

Existing tests continue to pass, ensuring backward compatibility with GitHub App permission error handling.

https://claude.ai/code/session_01AjW2wHdpAqzdugENctTaib

When GitHub Copilot returns a 403 with "not licensed to use Copilot",
the user's account lacks an active Copilot subscription — not a GitHub
App permissions issue. Previously, all Copilot 403s were treated as
`github_app_permissions` failures, which caused the "Update GitHub App
Permissions" modal to be shown incorrectly.

Now, 403 responses containing "not licensed" are surfaced as a `generic`
failure with a clear licensing message, so the permissions modal is
only shown for actual GitHub App permission issues.

https://claude.ai/code/session_01AjW2wHdpAqzdugENctTaib
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 19, 2026
@JoshFerge JoshFerge marked this pull request as ready for review February 19, 2026 21:31
@JoshFerge JoshFerge requested review from a team as code owners February 19, 2026 21:31
@JoshFerge JoshFerge requested a review from sehr-m February 19, 2026 21:31
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

The same Copilot 403 handling bug existed in the explorer path
(coding_agent_handoff.py). Licensing errors ("not licensed to use
Copilot") were incorrectly classified as github_app_permissions,
showing the permissions modal instead of a licensing message.

https://claude.ai/code/session_01AjW2wHdpAqzdugENctTaib
patch("sentry.seer.autofix.coding_agent.store_coding_agent_states_to_seer"),
):
response = self.get_success_response(self.organization.slug, method="post", **data)
assert response.data["success"] is True
Copy link
Member

Choose a reason for hiding this comment

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

Success should be true and failed count > 1?

success: True when all repos fail is misleading. Change success to be
len(successes) > 0 so it's False when no agents launched, and update
test assertions accordingly.

https://claude.ai/code/session_01AjW2wHdpAqzdugENctTaib
@JoshFerge JoshFerge merged commit 6cfe5b5 into master Feb 20, 2026
78 checks passed
@JoshFerge JoshFerge deleted the claude/debug-copilot-403-error-eUY9I branch February 20, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-code-assisted Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants