URI error on getting gravatar elixir v1.10.0-rc.0

Hi guys I tried to upgrade into latest elixir version which is 1.10 by using a version manager (kiex). Then, I encountered an issue

:path in URI must be nil or an absolute path if :host or :authority are given, got: %URI{authority: nil, fragment: nil, host: "secure.gravatar.com/avatar/", path: "e64c7d89f26bd1972efa854d13d7dd61", port: nil, query: "s=120", scheme: "https", userinfo: nil}

I tried to access a gravatar but it showed an error like this one, How can I resolve this one?

1 Like

Seems like the error was added in 1.10. Whatever you’re using for gravatar retrieval probably needs an update for 1.10 compatibility by making sure the path it actually an absolute one.

1 Like

Thanks @LostKobrakai.

Where do you get this URI from? It doesn’t have a valid host which is a bigger problem IMO.

Instead of

host: "secure.gravatar.com/avatar/", path: "e64c7d89f26bd1972efa854d13d7dd61"

it should be

host: "secure.gravatar.com", path: "/avatar/e64c7d89f26bd1972efa854d13d7dd61"

While it may not be a problem in your particular use case, you can see what this could lead to if you were to add a port number, for example:

iex(2)> %URI{
  authority: nil,
  fragment: nil,
  host: "secure.gravatar.com/avatar/",
  path: "e64c7d89f26bd1972efa854d13d7dd61",
  port: nil,
  query: "s=120",
  scheme: "https",
  userinfo: nil
} |> to_string()
"https://secure.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=120"

iex(3)> %URI{ 
  authority: nil,
  fragment: nil,
  host: "secure.gravatar.com/avatar/",
  path: "e64c7d89f26bd1972efa854d13d7dd61",
  port: 4000,
  query: "s=120",
  scheme: "https",
  userinfo: nil
} |> to_string()
"https://secure.gravatar.com/avatar/:4000e64c7d89f26bd1972efa854d13d7dd61?s=120"

@LostKobrakai ,
I’m very new to elixir and I’m just using it to setup an open source project that I need so I don’t know how to do the update you were talking about in your answer.

could you please show me how to do that ?
this is the error message

[error] #PID<0.1006.0> running Opencov.Endpoint terminated
Server: 0.0.0.0:4000 (http)
Request: GET /projects/new
** (exit) {%ArgumentError{message: ":path in URI must be nil or an absolute path if :host or :authority are given, got: %URI{authority: nil, fragment: nil, host: \"secure.gravatar.com/avatar/\", path: \"e64c7d89f26bd1972efa854d13d7dd61\", port: nil, query: \"s=24\", scheme: \"https\", userinfo: nil}"}, []}

Thanks in advance
Best