Skip to content

GitHub CLI returns 404 Not Found for private repository PR comments despite having access #11363

@archulan

Description

@archulan

Describe the bug

When using GitHub CLI to fetch PR comments from a private repository that the authenticated user has access to, the commands return '404 Not Found' errors even though the user can access the repository and PR through the web interface.

Steps to reproduce

  1. Authenticate with a GitHub token that has access to a private repository
  2. Run gh pr view --json number,headRepository (works correctly)
  3. Run gh api /repos/{owner}/{repo}/issues/{pr_number}/comments
  4. Run gh api /repos/{owner}/{repo}/pulls/{pr_number}/comments

Expected behavior

The commands should return the PR comments in JSON format, similar to how they work for public repositories.

Actual behavior

Both commands return:

gh: Not Found (HTTP 404)
{"message":"Not Found","documentation_url":"https://docs.github.com/rest/issues/comments#list-issue-comments","status":"404"}

Environment

  • GitHub CLI version: $(gh --version | head -1)
  • Operating system: macOS
  • Repository type: Private
  • Authentication: Personal Access Token with repo permissions

Additional context

  • The same API endpoints work correctly when called directly with curl using the same authentication token
  • The user has admin access to the repository
  • The PR exists and has comments visible in the GitHub web interface
  • Other gh commands work correctly with the same repository (e.g., gh pr list, gh pr view)

This issue affects workflows that depend on programmatically accessing PR comments for automation purposes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsplatformProblems with the GitHub platform rather than the CLI client

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions