fmcgeough
Another Dialyzer puzzle - 'Function will never be called'
I’m using the elixir-google-api/clients/sheets at main · googleapis/elixir-google-api · GitHub project (a thin wrapper over the Google Sheets API) to create a Google sheet. The module that creates the sheets for us has a number of Dialyzer warnings but they are all the same root cause I’d imagine. The warning is “Function get_spreadsheet/1 will never be called” (where get_spreadsheet/1 is just an example).
Here’s the lead to that issue:
defp create_google_sheet(nil) do
Logger.info("No spreadsheet exists, creating one")
month = @months[DateTime.utc_now().month]
create_google_connection()
|> Spreadsheets.sheets_spreadsheets_create(
body: %{properties: %{title: "#{month}-#{DateTime.utc_now().year}-Deployment/Build Report"}}
)
|> get_spreadsheet()
end
The get_spreadsheet is just a shim to parse out the {:ok, response} or :error returned by sheets_spreadsheets_create. Here’s the one
defp get_spreadsheet(result) do
case result do
{:ok, response} -> response
{:error, _env} -> nil
end
end
Spreadsheets.sheets_spreadsheets_create spec is:
@spec sheets_spreadsheets_create(Tesla.Env.client, keyword()) :: {:ok, GoogleApi.Sheets.V4.Model.Spreadsheet.t} | {:error, Tesla.Env.t}
This functions fine. We’ve been running it in production for a month or so and it does exactly what we want but it bothers me that I don’t understand what dialyzer is trying to tell me. Any suggestions on what to look at?
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance











First 9 of 9 Posts
dom
“Function get_spreadsheet/1 will never be called” is just fallout from the real error. What does dialyzer say before that?
NobbZ
Dialyzed doesn’t see a valid way that
create_google_sheet/1will ever be called with nil argument therefore it assumes functions called from it will never be called.At least that’s my assumption from what you have shown.
fmcgeough
The first warning that Dialyzer outputs is related to that get_spreadsheet/1 call. it does not warn about the create_google_connection/0 or the Spreadsheets.sheets_spreadsheets_create function calls. If I make that get_spreadsheet function public it doesn’t change the warnings that dialyzer produces.
NobbZ
Can you provide a minified project that produces similar warnings?
Or is the original projects source publicly available?
fmcgeough
thanks. Let me get that together. its a private project for my company but I can extract this issue. will post again when its available.
fmcgeough
Here’s a public repo that demos the issue. https://github.com/fmcgeough/google_sheet_dialyer
NobbZ
The PLT is building right now, I’ll take a look at it as my family gives me the time
OvermindDL1
I’m kind of thinking it dies on the
Spreadsheets.sheets_spreadsheets_createcall from just an initial look?EDIT: This is the dialyzer results if anyone is curious on that repo:
NobbZ
Its an upstream issue:
edit
I took the freedom to file an issue:
https://github.com/GoogleCloudPlatform/elixir-google-api/issues/73