Skip to content

CLI reports delete_repo scope needed on 403 for /dependabot/alerts endpoint #14962

Open

Description

@jackatpitch

Describe the bug

When using the gh CLI, when hitting the /repos/$ORG/$REPO/dependabot/alerts endpoint, a 403 error is accompanied by the message "gh: This API operation needs the "delete_repo" scope."

Affected version

gh version 2.103.3 (2026-10-26)
https://github.com/cli/cli/releases/tag/v2.103.3

Steps to reproduce the behavior

  1. Create a repo
  2. Do not enable dependabot alerts for it and/or have a token that doesn't no have permissions to read the alerts
  3. List them via the CLI

Expected vs actual behavior

Expected: The error message says what scopes are actually needed.

Actual: The error messages tells me I need to be able to delete my repo in order to read security alerts.

Logs

GH_DEBUG=api gh api -H 'Accept: application/vnd.github+json' -H 'X-GitHub-Api-Version: 2026-03-10' --paginate --jq '.[]' '/repos/$ORG/$REPO/dependabot/alerts?state=open&per_page=100'
* Request to https://api.github.com/repos/$ORG/$REPO/dependabot/alerts?state=open&per_page=100
> GET /repos/$ORG/$REPO/dependabot/alerts?state=open&per_page=100 HTTP/1.1
> Host: api.github.com
> Accept: application/vnd.github+json
> Content-Type: application/json; charset=utf-8
> User-Agent: GitHub CLI 2.103.3
> X-Github-Api-Version: 2026-03-10

< HTTP/2.0 403 Forbidden
< Content-Type: application/json; charset=utf-8
< Server: github.com
< X-Accepted-Oauth-Scopes: admin:repo_hook, delete_repo, read:repo_hook, repo, repo:invite, repo:status, repo_deployment, security_events, write:repo_hook
< X-Github-Api-Version-Selected: 2026-03-10
< X-Github-Media-Type: github.v3; format=json
< X-Oauth-Scopes: admin:public_key, admin:repo_hook, gist, read:org, repo

{
  "message": "Dependabot alerts are disabled for this repository.",
  "documentation_url": "https://docs.github.com/rest/dependabot/alerts#list-dependabot-alerts-for-a-repository",
  "status": "403"
}

* Request took 523.382517ms
{
  "message": "Dependabot alerts are disabled for this repository.",
  "documentation_url": "https://docs.github.com/rest/dependabot/alerts#list-dependabot-alerts-for-a-repository",
  "status": "403"
}
gh: Dependabot alerts are disabled for this repository. (HTTP 403)
gh: This API operation needs the "delete_repo" scope. To request it, run:  gh auth refresh -h github.com -s delete_repo

Activity

  1. added
    needs-triage
    on Nov 6, 2026
  2. cli-triage commented on Nov 6, 2026

    @cli-triage

    Reproducible on 2.103.3.

    Using test data with the reported accepted and held scope headers:

    $ gh api '/repos/octo/hello/dependabot/alerts?state=open&per_page=100'
    gh: Dependabot alerts are disabled for this repository. (HTTP 403)
    gh: This API operation needs the "delete_repo" scope. To request it, run:  gh auth refresh -h github.com -s delete_repo

    Exit status: 1.

    The latest release build and source revision c235ae3 produced the same misleading hint. The actual 403 reason remains visible, but the suggested remediation is incorrect.

    Supporting reports

    Generated by issue triage.

  3. deleted a comment from cli-triage on Nov 6, 2026
  4. added
    bug
    gh-api
    priority-3
    on Nov 6, 2026
  5. removed
    needs-triage
    on Nov 6, 2026
  6. wUEZRs commented on Nov 17, 2026

    @wUEZRs

    Another repro of the misleading scope hint, on the enterprise billing budgets endpoint:

    PATCH /enterprises/{enterprise}/settings/billing/budgets/{budget_id}
    X-Accepted-OAuth-Scopes: admin:enterprise, manage_billing:enterprise
    X-OAuth-Scopes: admin:enterprise
    HTTP 400
    {"message":"Budget alerts are not supported for user-scoped budgets."}
    

    With gh 2.103.3, the actual validation error is followed by:

    gh: This API operation needs the "manage_billing:enterprise" scope. To request it, run: gh auth refresh -h ... -s manage_billing:enterprise
    

    But GitHub's OAuth scope documentation says admin:enterprise includes manage_billing:enterprise. In this case the response is a budget validation error, not a missing authorization scope, so the suggested reauthorization is unnecessary. It looks like the same issue: the CLI compares X-Accepted-OAuth-Scopes with the token scopes but doesn't account for this parent-scope implication.

  7. added
    needs-investigation
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggh-apineeds-investigationpriority-3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions