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

[Bug] Handle error message if expired/invalid Github Token is used #5449

Closed
r15ch13 opened this issue Mar 28, 2023 · 2 comments · Fixed by #5424
Closed

[Bug] Handle error message if expired/invalid Github Token is used #5449

r15ch13 opened this issue Mar 28, 2023 · 2 comments · Fixed by #5424
Labels

Comments

@r15ch13
Copy link
Member

r15ch13 commented Mar 28, 2023

Bug Report

Current Behavior

If the configured Github Token gh_token is expired or invalid then a unhandled error message is shown

Expected Behavior

Handle message and suggest actions to user

Additional context/output

Installing 'fancontrol' (152) [64bit] from extras bucket
Invoke-RestMethod: X:\~projects\~powershell\scoop\lib\core.ps1:1241:14
Line |
1241 |if ((Invoke-RestMethod -Uri $privateUrl -Headers $headers).Pri …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest"}
Starting download with aria2 ...

How to reproduce

scoop config gh_token asdf
scoop install <app>

System details

Windows version: [e.g. 7, 8, 10, 11]

OS architecture: [e.g. 32bit, 64bit, arm64]

PowerShell version: [output of "$($PSVersionTable.PSVersion)"]

Additional software: [(optional) e.g. ConEmu, Git]

Scoop Configuration

{
  "debug": true,
  "gh_token": "asdf",
  "aria2-warning-enabled": false,
  "scoop_branch": "develop",
  "scoop_repo": "https://github.com/ScoopInstaller/Scoop"
}
@r15ch13 r15ch13 added the bug label Mar 28, 2023
@maokwen
Copy link

maokwen commented May 19, 2023

Downloading new version
OperationStopped: C:\Users\maokw\scoop\apps\scoop\current\lib\install.ps1:111
Line |
 111 |          throw $e
     |          ~~~~~~~~
     | Response status code does not indicate success: 401 (Unauthorized).

@fvydjt
Copy link

fvydjt commented Aug 19, 2023

This bug is really annoying. I encountered it and it wasted me a lot of time. What's more, I can't even find similar issues by searching the error message. Then I guess the problem may be caused by gh_token so I get here finally. By the way, it seems that the scoop wiki doesn't introduce the config.json.

behavior:
If aria2-enabled is true, it will show:

Invoke-RestMethod : {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest"}
At C:\Users\username\scoop\apps\scoop\current\lib\core.ps1:1158 char:14
+ ...        if ((Invoke-RestMethod -Uri $privateUrl -Headers $headers).Pri ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

else if aria2-enabled is false, it will show:

The remote server returned an error: (401) Unauthorized.
At C:\Users\username\scoop\apps\scoop\current\lib\install.ps1:111 char:9
+         throw $e
+         ~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], WebException
    + FullyQualifiedErrorId : The remote server returned an error: (401) Unauthorized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants