fix: log swallowed errors in integration connection test

the catch-all error handler was silently discarding the error reason,
making it impossible to debug failures. add logging and a specific
handler for graphql validation errors.
This commit is contained in:
Graham McIntire 2026-02-13 13:53:50 -06:00
parent c01f638d3a
commit 37ea526c61
No known key found for this signature in database

View file

@ -7,6 +7,8 @@ defmodule ToweropsWeb.Org.IntegrationsLive do
alias Towerops.Integrations.Integration
alias Towerops.Preseem.Client, as: PreseemClient
require Logger
@providers [
%{
id: "preseem",
@ -209,7 +211,12 @@ defmodule ToweropsWeb.Org.IntegrationsLive do
defp format_connection_result({:error, %{reason: :nxdomain}}), do: {:error, "DNS lookup failed - check API endpoint"}
defp format_connection_result({:error, {:graphql_errors, errors}}),
do: {:error, "API query failed: #{inspect(Enum.map(errors, & &1["message"]))}"}
# Never expose internal error details to users
defp format_connection_result({:error, _reason}),
do: {:error, "Connection failed - please check your API credentials and try again"}
defp format_connection_result({:error, reason}) do
Logger.warning("Integration connection test failed: #{inspect(reason)}")
{:error, "Connection failed - please check your API credentials and try again"}
end
end