Skip to content

errors in autopatch_mix when package not in Hex #1038

@artman41

Description

@artman41

When autopatching a mix.exs file. the below case statement can fail if the Hex repo used does not contain the version of the package being checked.

erlang.mk/core/elixir.mk

Lines 37 to 48 in 973ccc3

case hex_repo:get_package(Config, atom_to_binary(Name)) of
{ok, {200, _RespHeaders, Package}} ->
#{releases := List} = Package,
{value, #{version := Version}} = lists:search(fun(#{version := Vsn}) ->
M = list_to_atom("Elixir.Version"),
F = list_to_atom("match?"),
M:F(Vsn, Req)
end, List),
{ok, Version};
{ok, {Status, _, Errors}} ->
{error, Status, Errors}
end

This can happen in an environment where access to hex.lb.local is restricted and dependencies are being pulled from git instead.

This results in {error,unverified} being returned by hex_repo:get_package/2

This should likely be handled as an actual failure but can be a valid expectation like the situation above

Could it be worth checking the fetch method of the dependency and ignoring the error if it's not from hex?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions