From a9c61f703da6d1a4aa5801dd2d51d84eaa8f4a0b Mon Sep 17 00:00:00 2001 From: Moritz Date: Tue, 10 Mar 2026 18:15:07 +0100 Subject: [PATCH] fix: resolve Mix.env at compile time in Vereinfacht client Mix.env() is not available in production releases. Use module attribute so it is only evaluated at compile time. --- lib/mv/vereinfacht/client.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/mv/vereinfacht/client.ex b/lib/mv/vereinfacht/client.ex index e7ca04c..3cbba71 100644 --- a/lib/mv/vereinfacht/client.ex +++ b/lib/mv/vereinfacht/client.ex @@ -92,10 +92,13 @@ defmodule Mv.Vereinfacht.Client do @sync_timeout_ms 5_000 + # Resolved at compile time so Mix is never called at runtime (Mix is not available in releases). + @env Mix.env() + # In test, skip retries so sync fails fast when no API is running (avoids log spam and long waits). defp req_http_options do opts = [receive_timeout: @sync_timeout_ms] - if Mix.env() == :test, do: [retry: false] ++ opts, else: opts + if @env == :test, do: [retry: false] ++ opts, else: opts end defp post_and_parse_contact(url, body, api_key) do