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

Handle empty package name in mix hex.info #1022

Merged
merged 2 commits into from
May 6, 2024

Conversation

sabiwara
Copy link
Contributor

@sabiwara sabiwara commented May 4, 2024

Currently, it fails as follows:

$ mix hex.info ""
** (ArgumentError) the Access module supports only keyword lists (with atom keys), got: "meta"

If you want to search lists of tuples, use List.keyfind/3
    (elixir 1.16.2) lib/access.ex:345: Access.get/3
    (hex 2.0.6) lib/mix/tasks/hex.info.ex:108: Mix.Tasks.Hex.Info.print_package/2

This is because we call GET packages/ on hexpm which returns a list of objects, not an object.

The second commit adds some guards on the API layer to calling the wrong URLs in the first place.

Note: While the mix hex.info "" command might not make sense as user input, it might happen when scripting.

Currently, it fails as follows:

$ mix hex.info ""
** (ArgumentError) the Access module supports only keyword lists (with atom keys), got: "meta"

If you want to search lists of tuples, use List.keyfind/3
    (elixir 1.16.2) lib/access.ex:345: Access.get/3
    (hex 2.0.6) lib/mix/tasks/hex.info.ex:108: Mix.Tasks.Hex.Info.print_package/2

This is because we call GET packages/ on hexpm which returns a list of objects.
Copy link
Member

@ericmj ericmj left a comment

Choose a reason for hiding this comment

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

Thank you!

@ericmj ericmj merged commit 39ebd09 into hexpm:main May 6, 2024
12 checks passed
@sabiwara sabiwara deleted the info_empty_name branch May 6, 2024 15:40
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