erlef / oidcc

OpenId Connect client library in Erlang & Elixir
https://hexdocs.pm/oidcc
Apache License 2.0
184 stars 49 forks source link

`Oidcc.ProviderConfiguration.Worker.child_spec` typespec problem #394

Closed LostKobrakai closed 3 weeks ago

LostKobrakai commented 3 weeks ago

oidcc version

3.2.4

Erlang version

27.1.2

Elixir version

1.17.3

Summary

Oidcc.ProviderConfiguration.Worker.child_spec takes :oidcc_provider_configuration_worker.opts() as parameter, which defines the :name map key as gen_server:server_name().

Current behavior

gen_server:server_name() is not a match for Elixir's GenServer.name and doesn't include a bare atom, which is transformed by Oidcc.ProviderConfiguration.Worker.start_link however.

How to reproduce

defmodule MyApp.OIDC.Provider do
  @spec child_spec(term) :: Supervisor.child_spec()
  def child_spec(_) do
    Oidcc.ProviderConfiguration.Worker.child_spec(%{
      name: __MODULE__,
      …
    })
  end
end

Add this to a project, run dialyzer, see error, e.g.:

ElixirLS Dialyzer: The function call will not succeed.

Oidcc.ProviderConfiguration.Worker.child_spec(%{:issuer => _, :name => Kasts.OIDC.GitLabProvider})

breaks the contract
(opts :: :oidcc_provider_configuration_worker.opts()) :: Supervisor.child_spec()

Expected behavior

Typespecs are correct.