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

judgeVersion panic when GITHUB_TOKEN env is set to an invalid token #138

Closed

Conversation

beppler
Copy link
Contributor

@beppler beppler commented Oct 1, 2023

I had an invalid GITHUB_TOKEN set on my account and this caused gobrew.ListRemoteVersions to return an empty list of versions.

Because the list is empty the code on gobrew.judgeVersion generates an panic as can be seen on the image bellow.

image

This PR contains a fix for the panic error.

Probably it is the same error reported on #135.

Copy link
Collaborator

@juev juev left a comment

Choose a reason for hiding this comment

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

Hello!
Thank you!

But I think that if we have a completed token and get an error from Github, it is better not to return an error, but to unset the GITHUB_TOKEN variable and try to make the request again.

By the way, we need to see what error we get from Github if the token is not filled correctly.

@kevincobain2000 what do you think?

@kevincobain2000
Copy link
Owner

kevincobain2000 commented Oct 1, 2023

Hmmm. I think we should just get rid of GitHub token completely and obtain the latest version from the raw.githubusercontent too like it is done for ls-remote on the branch:json

basically not rely on git tags at all.

@juev
Copy link
Collaborator

juev commented Oct 1, 2023

Hmmm. I think we should just get rid of GitHub token completely and obtain the latest version from the raw.githubusercontent too like it is done for ls-remote on the branch:json

We use tags in two places:

  1. for the go/golang repository
  2. for the gobrew repository to get the latest version

And if for Golang we can use json from a separate branch, then for gobrew I do not yet understand what can be used.

And so it's a great idea, we need to think about it in more detail.

@@ -98,6 +98,7 @@ func TestJudgeVersion(t *testing.T) {
// wantVersion: "1.19.1",
// },
}
os.Unsetenv("GITHUB_TOKEN")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there's no need to remove this variable in the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed because otherwise the test would fail as my environment had the broken token.

Maybe we can keep this and create a new one that exposes the error using a broken token?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I created a separate request in which we get rid of the token

Copy link
Owner

Choose a reason for hiding this comment

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

So we close this pull req?

To @juev
Would you please do the merges and make the release by pushing the release tag?

Thanks

Copy link
Collaborator

Choose a reason for hiding this comment

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

So we close this pull req?

To @juev Would you please do the merges and make the release by pushing the release tag?

Thanks

ok

@kevincobain2000
Copy link
Owner

kevincobain2000 commented Oct 1, 2023

Hmmm. I think we should just get rid of GitHub token completely and obtain the latest version from the raw.githubusercontent too like it is done for ls-remote on the branch:json

We use tags in two places:

for the go/golang repository
for the gobrew repository to get the latest version
And if for Golang we can use json from a separate branch, then for gobrew I do not yet understand what can be used.

And so it's a great idea, we need to think about it in more detail.

I think we can just create a new branch called version, and in the release.yml, after goreleaser has done making the release, push current gobrew version to version.txt file on branch:version. Which can then be used via raw.githubusercontent when gobrew wants to check it's own version.

I don't think there is an industry standard right now that we can follow, all we need is to get the current version somewhere from the internet, and raw.githubusercontent is a rate limit safe place to put it.

PS: In npm we can just refer to the package.json but not in GO

@beppler
Copy link
Contributor Author

beppler commented Oct 1, 2023

Hey guys, can I close this one as #140 fixes it in another way?

@juev
Copy link
Collaborator

juev commented Oct 1, 2023

Hey guys, can I close this one as #140 fixes it in another way?

I think so, thank you!

@beppler beppler closed this Oct 1, 2023
@beppler beppler deleted the bug/judge-version-panic branch October 1, 2023 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants