Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/gist-logs: On 404, the PAT probably needs more permissions #14523

Merged

Conversation

issyl0
Copy link
Member

@issyl0 issyl0 commented Feb 6, 2023

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

  • This 404 error is from GitHub, and GitHub doesn't give us any more informations about scopes for the gist endpoint (for some reason). But we can safely assume, as it happens a lot, that "Error: Not Found" (404) is because the user hasn't granted their HOMEBREW_GITHUB_API_TOKEN the gist scope.
  • Fixes Improve error message for GitHub API token permission failure #13988.

Before:

$ HOMEBREW_GITHUB_API_TOKEN=<token_without_gist_scope> brew gist-logs -p logrotate
Error: Not Found

After:

❯ HOMEBREW_GITHUB_API_TOKEN=<token_without_gist_scope> brew gist-logs logrotate
Error: Your GitHub API token likely doesn't have the `gist` scope.
Create a GitHub personal access token:
https://github.com/settings/tokens/new?scopes=gist&description=Homebrew
echo 'export HOMEBREW_GITHUB_API_TOKEN=your_token_here' >> ~/.zshrc

@BrewTestBot
Copy link
Member

Review period will end on 2023-02-07 at 15:17:35 UTC.

@BrewTestBot BrewTestBot added the waiting for feedback Merging is blocked until sufficient time has passed for review label Feb 6, 2023
@issyl0 issyl0 force-pushed the gist-logs-better-token-permissions-message branch from e6a2ce1 to 3b092eb Compare February 6, 2023 15:34
- This 404 error is from GitHub, and GitHub doesn't give us any more
  informations about scopes for the gist endpoint (for some reason). But we can
  safely assume, as it happens a lot, that "Error: Not Found" (404) is because
  the user hasn't granted their `HOMEBREW_GITHUB_API_TOKEN` the `gist` scope.

Before:

```shell
$ HOMEBREW_GITHUB_API_TOKEN=<token_without_gist_scope> brew gist-logs -p logrotate
Error: Not Found
```

After:

```shell
❯ HOMEBREW_GITHUB_API_TOKEN=<token_without_gist_scope> brew gist-logs logrotate
Error: Your GitHub API token likely doesn't have the `gist` scope.
Create a GitHub personal access token:
https://github.com/settings/tokens/new?scopes=gist&description=Homebrew
echo 'export HOMEBREW_GITHUB_API_TOKEN=your_token_here' >> ~/.zshrc
```
@issyl0 issyl0 force-pushed the gist-logs-better-token-permissions-message branch from 3b092eb to 41b143d Compare February 6, 2023 16:00
@MikeMcQuaid MikeMcQuaid added the critical Critical change which should be shipped as soon as possible. label Feb 6, 2023
@BrewTestBot BrewTestBot removed the waiting for feedback Merging is blocked until sufficient time has passed for review label Feb 6, 2023
@BrewTestBot
Copy link
Member

Review period skipped due to critical label.

Copy link
Member

@Bo98 Bo98 left a comment

Choose a reason for hiding this comment

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

These are in nested modules/classes so need to be fully qualified.

Error: undefined local variable or method `pat_blurb' for #GitHub::API::RateLimitExceededError:0x00007fd0d6af2c98

Library/Homebrew/utils/github/api.rb Outdated Show resolved Hide resolved
Library/Homebrew/utils/github/api.rb Outdated Show resolved Hide resolved
Library/Homebrew/utils/github/api.rb Outdated Show resolved Hide resolved
Library/Homebrew/utils/github/api.rb Outdated Show resolved Hide resolved
@Bo98 Bo98 disabled auto-merge February 7, 2023 00:56
Co-authored-by: Bo Anderson <mail@boanderson.me>
@issyl0
Copy link
Member Author

issyl0 commented Feb 7, 2023

Thanks @Bo98, I hadn’t seen the CI failures yet.

@EricFromCanada
Copy link
Member

Does no one here sleep??

@Bo98
Copy link
Member

Bo98 commented Feb 7, 2023

Does no one here sleep??

That'll be on my todo list somewhere.

@Bo98 Bo98 enabled auto-merge February 7, 2023 01:29
@Bo98 Bo98 merged commit 2bb5cda into Homebrew:master Feb 7, 2023
@MikeMcQuaid
Copy link
Member

Does no one here sleep??

That'll be on my todo list somewhere.

@Bo98 I thought we talked about this: add a help wanted issue and someone might sleep for you so you don't have to 😂

@issyl0 issyl0 deleted the gist-logs-better-token-permissions-message branch February 8, 2023 22:56
@github-actions github-actions bot added the outdated PR was locked due to age label Mar 11, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
critical Critical change which should be shipped as soon as possible. outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error message for GitHub API token permission failure
5 participants