Fl4m3Ph03n1x

Fl4m3Ph03n1x

Dialyzer giving warnings that make no sense

Background

I have recently started trying out dialyxir. After playing around with a few pet projects I decided to up the game and try it into something more real.

Problem

However, dialyxir is giving me warnings that make no sense whatsoever. Thanks to the success algorithm dialyzer uses, I would expect it to not find every possible error which is fine, but giving me so many false positives ( which should be impossible ) is definitely something I was not expecting - it completely ruins the experience with noisy warnings that are useless.

Have a look on the following behaviour:

defmodule MyApp.Web.MetricsInstrumenter do
  @moduledoc """
  Adds HTTP related metrics for every request.
  See used Prometheus.PlugPipelineInstrumenter module for details.
  """
  use Prometheus.PlugPipelineInstrumenter
end

This created the following dialyxir warning:

lib/myapp/web/metrics_instrumenter.ex:6:guard_fail
Guard test:
tuple_size(_ :: Exception.t())

can never succeed.

This is mind blowing. This makes no sense whatsoever. There is literally only 1 line of code and that line doesn’t even have a when clause.

Why am I getting this error?

Questions

I keep thinking this is a configuration problem. Somehow, I am not configuring the app correctly in the mix.exs file while using Prometheus.

defmodule MyApp.MixProject do
  @moduledoc false
  use Mix.Project

  def project do
    [
      app: :myaap,
      version: "1.1.0",
      elixir: "~> 1.7",
      elixirc_paths: elixirc_paths(Mix.env()),
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end

  def application do
    [
      extra_applications: [:logger],
      mod: {MyApp.Application, []}
    ]
  end

  defp deps do
    [
      { :plug,              "~> 1.0"  },
      { :prometheus_plugs,  "~> 1.1.5"  },
      { :prometheus_ex,     "~> 3.0"  },
      { :dialyxir,          "~> 1.0.0-rc.4",  only: [:dev],         runtime: false  }
    ]
  end

  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(:dev), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]
end

But nothing I do works.
Why am I getting these non nonsensical errors?

Marked As Solved

NobbZ

NobbZ

Its already reported and closed:

I’m not sure though, if the fix is in the 1.7 branch or only for 1.8.

Also Liked

NobbZ

NobbZ

Thats hard to tell from this perspective, but probably something in prometheus is faulty?

In general it makes totally sense that tuple_size/1 called with an exception as argument would not suceed. Problem is though, I can not find any reference to tuple_size/1 in either prometheus_plugs, nor prometheus_ex.

So this problem might be burried even deeper.


edit

Can’t even find tuple_size it in the underlying erlang library. I’m trying to dig into this locally. Dialyzer is building its PLT right now…

Fl4m3Ph03n1x

Fl4m3Ph03n1x

@NobbZ Just to make it clear, I truly appreciate all the help you are giving. Without you this forum wouldn’t be what it is today.

Thank you.


On a separate note, if this is an issue with Prometheus, what are the options?

  1. make a PR to fix it?
  2. ask dialyzer to ignore prometheus_ex ? ( not sure if even possible )
NobbZ

NobbZ

Spoiler warning… I sshd into my system at home which runs 1.7/21. It triggers the same errors as you report. Ill have to play a bit with versions to learn more…

Where Next?

Popular in Questions Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30877 112
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31142 143
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement