secure_random.ex
secure_random.ex copied to clipboard
Base.encode64 and url_encode64 do not accept :case as a valid option
Hello!
This PR results from an error raised by Dialyzer, when using SecureRandom.base64() or SecureRandom.urlsafe_base64() in a function foo/0:
Function foo/0 has no local return.
While digging further, it turns out that Dialyzer raises because Base.encode64() and Base.url_encode64() do not support a :case option:
The function call will not succeed.
Base.encode64(binary(), [{:case, :lower}])
breaks the contract
(binary(), [{:padding, boolean()}]) :: binary()
See the recent elixir docs: https://hexdocs.pm/elixir/Base.html#url_encode64/2 & https://hexdocs.pm/elixir/Base.html#encode64/2.
I'm not sure if the option ever made sense (or why Dialyzer didn't raise this ealier in my project 🤷♀️) - but I hope the PR will at least help other peeps running into this issue, as the original Dialyzer error is cryptic 🥸.