Compilation errors with oauth2 2.0
Closed this issue · 3 comments
lubien commented
Elixir and Erlang/OTP versions
elixir --version
Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:14:14] [ds:14:14:10] [async-threads:1] [jit]
Elixir 1.18.4 (compiled with Erlang/OTP 27)
Operating system
Mac M4 2025
Current behavior
I was trying to update our elixir version from elixir 1.17.2-otp-27 to 1.18.4-otp-27 (using asdf) and got these compilation errors specifically on oauth2 (2.0) library that asked me to post the bug here:
==> oauth2
Compiling 13 files (.ex)
** (EXIT from #PID<0.94.0>) an exception was raised:
** (RuntimeError) found error while checking types for OAuth2.Request.request!/6:
** (RuntimeError) found error while checking types for OAuth2.Request.request/6:
** (MatchError) no match of right hand side value: {:EXIT, {:badarg, [{:erlang, :binary_to_atom, [<<104, 97, 99, 107, 110, 101, 121, 112, 99, 111, 110, 110, 101, 99, 116, 176, 104, 97, 99, 107, 110, 101, 121, 95, 117, 114, 108, 144, 112, 97, 114, 115, 101, 95, 117, 114, 108, 240, 104, 97, 99, ...>>, :utf8], [error_info: %{module: :erl_erts_errors}]}, {:beam_lib, :extract_atom, 2, [file: ~c"beam_lib.erl", line: 1217]}, {:beam_lib, :get_atom_data, 8, [file: ~c"beam_lib.erl", line: 981]}, {:beam_lib, :scan_beam1, 2, [file: ~c"beam_lib.erl", line: 942]}, {:beam_lib, :scan_beam, 4, [file: ~c"beam_lib.erl", line: 927]}, {:beam_lib, :read_chunk_data, 3, [file: ~c"beam_lib.erl", line: 899]}, {:beam_lib, :read_chunk_data, 2, [file: ~c"beam_lib.erl", line: 890]}, {Module.ParallelChecker, :cache_module, 2, [file: ~c"lib/module/parallel_checker.ex", line: 381]}]}}
The exception happened while checking this code:
def request(method, %OAuth2.Client{} = client, url, body, headers, opts) do
url = process_params(process_url(client, url), opts[:params])
headers = Enum.uniq(req_headers(client, headers))
content_type = OAuth2.Util.content_type(headers)
serializer = OAuth2.Client.get_serializer(client, content_type)
body = encode_request_body(body, content_type, serializer)
headers = process_request_headers(headers, content_type)
req_opts = Keyword.merge(client.request_opts, opts)
case Application.get_env(:oauth2, :debug) do
x when :erlang.orelse(:erlang."=:="(x, false), :erlang."=:="(x, nil)) ->
nil
_ ->
case Logger.__should_log__(:debug, OAuth2.Request) do
nil ->
:ok
level ->
Logger.__do_log__(
level,
<<" OAuth2 Provider Request\n url: ", Kernel.inspect(url)::binary, "\n method: ",
Kernel.inspect(method)::binary, "\n headers: ", Kernel.inspect(headers)::binary,
"\n body: ", Kernel.inspect(body)::binary, "\n req_opts: ",
Kernel.inspect(req_opts)::binary, "\n">>,
%{file: ~c"lib/oauth2/request.ex", line: 26, mfa: {OAuth2.Request, :request, 6}},
%{application: :oauth2}
)
end
end
case :hackney.request(method, url, headers, body, req_opts) do
{:ok, ref} when :erlang.is_reference(ref) ->
{:ok, ref}
{:ok, status, headers, ref} when :erlang.is_reference(ref) ->
process_body(client, status, headers, ref)
{:ok, status, headers, body} when :erlang.is_binary(body) ->
process_body(client, status, headers, body)
{:error, reason} ->
{:error, %OAuth2.Error{__exception__: true, reason: reason}}
end
end
Please report this bug at: https://github.com/elixir-lang/elixir/issues
The exception happened while checking this code:
def request!(method, %OAuth2.Client{} = client, url, body, headers, opts) do
case request(method, client, url, body, headers, opts) do
{:ok, resp} ->
resp
{:error, %OAuth2.Response{status_code: code, headers: headers, body: body}} ->
:erlang.error(
Kernel.Utils.raise(%OAuth2.Error{
__exception__: true,
reason:
<<"Server responded with status: ", String.Chars.to_string(code)::binary,
"\n\nHeaders:\n\n",
String.Chars.to_string(
Enum.reduce(headers, "", fn {k, v}, acc ->
<<acc::binary, String.Chars.to_string(k)::binary, ": ",
String.Chars.to_string(v)::binary, "\n">>
end)
)::binary, "\nBody:\n\n", Kernel.inspect(body)::binary, "\n">>
}),
:none,
error_info: %{module: Exception}
)
{:error, error} ->
:erlang.error(Kernel.Utils.raise(error), :none, error_info: %{module: Exception})
end
end
Please report this bug at: https://github.com/elixir-lang/elixir/issues
(stdlib 6.0.1) beam_lib.erl:899: :beam_lib.read_chunk_data/3
(stdlib 6.0.1) beam_lib.erl:890: :beam_lib.read_chunk_data/2
(elixir 1.18.4) lib/module/parallel_checker.ex:381: Module.ParallelChecker.cache_module/2
(elixir 1.18.4) lib/module/parallel_checker.ex:207: Module.ParallelChecker.fetch_export/4
(elixir 1.18.4) lib/module/types/apply.ex:523: Module.Types.Apply.export/6
(elixir 1.18.4) lib/module/types/apply.ex:441: Module.Types.Apply.remote/6
(elixir 1.18.4) lib/module/types/expr.ex:263: Module.Types.Expr.of_expr/3
(elixir 1.18.4) lib/module/types.ex:245: anonymous fn/6 in Module.Types.local_handler/7
Expected behavior
Code compiles
SteffenDE commented
@lubien did you briefly use Erlang/OTP 28? A similar error was reported multiple times when people had code compiled for OTP 28 in their _build folder. Please try to remove _build and see if the error disappears :)
lubien commented
@SteffenDE That is correct, now everything compiles successfully (with expected type check warning)! Sorry about the red herring
josevalim commented
Yup, and this is fixed to automatically recompile in more recent Elixir versions!