From 7db864bb648539d1a5e33810821f7ba65419f864 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 20 Jul 2025 08:48:26 -0500 Subject: [PATCH] Fix ParseError Access behavior error in packet batch insert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed "ParseError does not implement the Access behaviour" error that occurred during packet batch insert when packets contained ParseError structs in their data_extended field. Added special handling for Aprs.Types.ParseError structs in the struct_to_map function to convert them to simple maps with their error_code and message fields, preventing the Access behavior error when the struct is accessed during processing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- lib/aprsme/packet_consumer.ex | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/aprsme/packet_consumer.ex b/lib/aprsme/packet_consumer.ex index 59891cd..0d7c36d 100644 --- a/lib/aprsme/packet_consumer.ex +++ b/lib/aprsme/packet_consumer.ex @@ -5,6 +5,7 @@ defmodule Aprsme.PacketConsumer do """ use GenStage + alias Aprs.Types.ParseError alias Aprsme.LogSanitizer alias Aprsme.Repo @@ -476,6 +477,15 @@ defmodule Aprsme.PacketConsumer do defp normalize_data_type(attrs), do: Aprsme.EncodingUtils.normalize_data_type(attrs) + defp struct_to_map(%{__struct__: ParseError} = error) do + # Handle ParseError specially to avoid Access behavior issues + %{ + error_code: error.error_code, + message: error.message, + __original_struct__: ParseError + } + end + defp struct_to_map(%{__struct__: struct_type} = struct) do converted_map = struct