Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dialyzer "no_return" on ExAws.S3.presigned_post #254

Open
unenglishable opened this issue Apr 11, 2024 · 1 comment
Open

dialyzer "no_return" on ExAws.S3.presigned_post #254

unenglishable opened this issue Apr 11, 2024 · 1 comment

Comments

@unenglishable
Copy link

Environment

  • Elixir & Erlang versions (elixir --version):
Elixir 1.14.4 (compiled with Erlang/OTP 25)
  • ExAws version mix deps |grep ex_aws
* ex_aws 2.5.3 (Hex package) (mix)
  locked at 2.5.3 (ex_aws) 67115f1d
* ex_aws_s3 2.5.3 (Hex package) (mix)
  locked at 2.5.3 (ex_aws_s3) 4f09dd37
  • HTTP client version. IE for hackney do mix deps | grep hackney
* hackney 1.20.1 (Hex package) (rebar3)
  locked at 1.20.1 (hackney) fe9094e5

Current behavior

code sample:

  def generate_presigned_post(%{filename: filename}) do
    config = Application.get_env(:server, __MODULE__)

    opts = [
      expires_in: config[:expire_after_hours],
      content_length_range: [config[:min_size_bytes], config[:max_size_bytes]],
      virtual_host: config[:virtual_host],
      starts_with: ["$Content-Type", config[:content_type_starts_with]]
    ]

    ExAws.Config.new(:s3, [])
    |> ExAws.S3.presigned_post(config[:bucket], config[:path] <> filename, opts)
  end

errors and stacktraces

> mix dialyzer

...
((module calling generate_presigned_post)):no_return
The created anonymous function has no local return.
________________________________________________________________________________
lib/server/s3.ex:10:no_return
Function generate_presigned_post/1 has no local return.
________________________________________________________________________________
done (warnings were emitted)
Halting VM with exit status 2

Expected behavior

dialyzer should succeed

when i remove the call to ExAws.S3.presigned_post dialyzer succeeds; it is the bottom function call in my project

this may be due to a bad @spec somewhere, i've recently fixed this issue by updating a @spec

i am fixing this temporarily in my project by configuring dialyzer to ignore generate_presigned_post

thank you for your consideration :)

@sc-yan
Copy link

sc-yan commented Aug 26, 2024

I had same issue with this function, stream_file. mix dialyzer would fail since the func is calling File.stream! under the hood, but S3.Upload.stream_file is not ending with ! mark.

the issue is fixed by this PR.
I fixed it by upgrading ex_aws_s3 from 2.3 to 2.5.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants