hexpm / hex

Package manager for the Erlang ecosystem.
https://hex.pm
961 stars 184 forks source link

Handle empty package name in mix hex.info #1022

Closed sabiwara closed 2 months ago

sabiwara commented 2 months ago

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.