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

Give a better error message if token contains newlines #221

Merged
merged 1 commit into from
Nov 24, 2023

Conversation

Keno
Copy link
Contributor

@Keno Keno commented Nov 22, 2023

I constructed a token as OAuth2(read("token", String)), but my token file had a trailing newline. GitHub stops parsing headers after an empty line, so depending on where the header ended up in the list of headers, this was causing all sorts of strange errors. Detect this situation and throw an intelligent error in GitHub.jl instead.

@Keno Keno force-pushed the kf/authtokenerror branch 2 times, most recently from 7d5947f to cee2dbb Compare November 24, 2023 12:45
@codecov-commenter
Copy link

codecov-commenter commented Nov 24, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c586ca7) 57.76% compared to head (fff5213) 58.13%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #221      +/-   ##
==========================================
+ Coverage   57.76%   58.13%   +0.37%     
==========================================
  Files          37       37              
  Lines         902      910       +8     
==========================================
+ Hits          521      529       +8     
  Misses        381      381              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -21,3 +21,5 @@ auth2 = GitHub.JWTAuth(1234, key; iat = DateTime("2016-9-15T14:00"))
# test to make sure things don't break.
@test auth.JWT == correct_jwt
@test auth2.JWT == correct_jwt

@test_throws ArgumentError GitHub.OAuth2("ghp_\n")
Copy link
Collaborator

Choose a reason for hiding this comment

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

In theory would be good to test the JWTAuth constructor as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

I constructed a token as `OAuth2(read("token", String))`, but my
token file had a trailing newline. GitHub stops parsing headers
after an empty line, so depending on where the header ended up
in the list of headers, this was causing all sorts of strange errors.
Detect this situation and throw an intelligent error in GitHub.jl instead.
@Keno Keno merged commit d24bd67 into master Nov 24, 2023
9 checks passed
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.

3 participants