From bbe1722c9fc007ce28335b7758660c0d6c08b13f Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Fri, 17 Apr 2026 07:10:45 +0100 Subject: [PATCH] Handle unencodable structs in QueryReporter params --- lib/music_library/query_reporter.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/music_library/query_reporter.ex b/lib/music_library/query_reporter.ex index f96b3119..3416d6b7 100644 --- a/lib/music_library/query_reporter.ex +++ b/lib/music_library/query_reporter.ex @@ -136,7 +136,14 @@ defmodule MusicLibrary.QueryReporter do end defp format_param(value) when is_list(value) or (is_map(value) and not is_struct(value)) do - "'" <> String.replace(JSON.encode!(value), "'", "''") <> "'" + encoded = + try do + JSON.encode!(value) + rescue + Protocol.UndefinedError -> inspect(value) + end + + "'" <> String.replace(encoded, "'", "''") <> "'" end defp format_param(value), do: "'" <> String.replace(to_string(value), "'", "''") <> "'"