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

DateTime.from_iso8601 returns unexpected tuple #4260

Open
brianmay opened this issue Oct 13, 2024 · 1 comment
Open

DateTime.from_iso8601 returns unexpected tuple #4260

brianmay opened this issue Oct 13, 2024 · 1 comment
Labels
area:teslamate Related to TeslaMate core elixir Pull requests that update Elixir code kind:bug Something isn't working

Comments

@brianmay
Copy link
Collaborator

brianmay commented Oct 13, 2024

date_earliest =
cond do
min_id == 0 ->
DateTime.add(DateTime.utc_now(), -10, :day)
true ->
DateTime.from_iso8601("2003-07-01T00:00:00Z")
end
naive_date_earliest = DateTime.to_naive(date_earliest)

If you look at the logs, there was is scary looking error that isn't generating a test failure:

** (FunctionClauseError) no function clause matching in DateTime.to_naive/1
    (elixir 1.16.2) lib/calendar/datetime.ex:925: DateTime.to_naive({:ok, ~U[2003-07-01 00:00:00Z], 0})
    (teslamate 1.30.2-dev) lib/teslamate/log.ex:185: TeslaMate.Log.get_positions_without_elevation/2
    (teslamate 1.30.2-dev) lib/teslamate/terrain.ex:77: TeslaMate.Terrain.handle_event/4
    (stdlib 5.2.3.2) gen_statem.erl:1397: :gen_statem.loop_state_callback/11
    (stdlib 5.2.3.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3

Problem is DateTime.from_iso8601 returns a tuple, and could in theory fail. Sigh. Wish Elixir had strong type checking...

In actual practice, this function call probably I think can't fail, the value is constant.

@brianmay
Copy link
Collaborator Author

I suspect (but haven't checked) the reason this didn't cause the tests to fail is because the errors occurred in another process, not the test process.

Which is somewhat unfortunate.

@JakobLichterfeld JakobLichterfeld added the kind:bug Something isn't working label Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:teslamate Related to TeslaMate core elixir Pull requests that update Elixir code kind:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants