Skip to content

[Bug] Triage Fails Silently for Private Repositories When Token Lacks Scope #78

Description

@anshul23102

Summary

When isscope is configured with a GitHub token that lacks the repo scope (only public_repo), triaging a private repository returns a generic error with no guidance. Users do not know what permission is missing.

Current Behavior

A 404 response from the GitHub API on a private repository returns a toast: "Repository not found." The actual cause (missing repo token scope) is not communicated.

Expected Behavior

The error message should detect the 404 on a known-private repository and explain that the configured token needs the repo scope to access private repositories, with a link to GitHub's token settings page.

Proposed Fix

async function fetchIssue(owner: string, repo: string, number: number) {
  const res = await fetch(`https://api.github.com/repos/${owner}/${repo}/issues/${number}`, {
    headers: { Authorization: `Bearer ${token}` }
  });

  if (res.status === 404) {
    const scopeHeader = res.headers.get('x-oauth-scopes') ?? '';
    const hasRepoScope = scopeHeader.split(',').map(s => s.trim()).includes('repo');

    if (!hasRepoScope) {
      throw new PermissionError(
        'Private repository access requires the `repo` OAuth scope. ' +
        'Update your token at https://github.com/settings/tokens.'
      );
    }
    throw new NotFoundError('Repository or issue not found.');
  }
}

Show the PermissionError in a persistent banner (not a dismissable toast) with a "Update token" link.

Acceptance Criteria

  • Triaging a private repo with a token missing repo scope shows the permission error banner.
  • The banner includes a direct link to the GitHub token settings page.
  • The banner persists until the user dismisses it or updates the token.
  • Public 404 errors still show the generic "not found" message.
  • A unit test mocks the 404 response with both scope scenarios.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions