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

Improve logging of auth issues #1007

Merged
merged 2 commits into from
Jan 2, 2024
Merged

Improve logging of auth issues #1007

merged 2 commits into from
Jan 2, 2024

Conversation

ream88
Copy link
Contributor

@ream88 ream88 commented Dec 29, 2023

It took me way too long to figure out that the person who set up the private hex.pm registry for me forgot to add billing credentials. I tried everything else because neither the web app nor the command line gave me a proper error. This PR hopefully changes this ;)

Comment on lines 280 to 281
{:ok, {code, _body, _}} when code in [401, 403] ->
Hex.Shell.error("Failed to authenticate against organization repository with given key")
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for the PR!

could you check if this clause is still relevant by, say, removing it and seeing if it breaks anything? I don't think we should be getting 401s/403s with or without messages, it should be one or the other ideally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it and my local tests are still passing. However the only potential issue I see with removing it, is that my code (%{"message" => message}) assumes that the response is JSON and can be parsed into a map with a message key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So my code could break if the API or for example a load balancer returns a body that is not valid JSON. Question is, if we should try to account for that or not. But that's up to you. :)

Copy link
Member

Choose a reason for hiding this comment

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

In that case we will fall through to the catch all at the end and we should be good unless I’m missing something. Please remove the redundant clause and I think we are good to go. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@wojtekmach wojtekmach merged commit 92b48e4 into hexpm:main Jan 2, 2024
10 of 11 checks passed
@wojtekmach
Copy link
Member

Thank you!

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.

2 participants