PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: newrelic/elixir_agent (elixir)

Issue:
Bad attribute on redis encoded string
**Describe the bug**

When calling `SET <string key> <encoded value>` the agent reports this as a "Bad attribute". We're using a library that calls `:erlang.binary_to_term` on the value before putting it into redis.

**Environment**
* Elixir & Erlang version (`elixir -v`): Erlang 24.0.6, Elixir 1.12.3
* Agent version (`mix deps | grep new_relic_agent`): 1.27.8


Pull request:
Handle binary attribute values better
We can write binary (but not string) attribute values as "[BINARY_VALUE]" instead of "[BAD_VALUE]", and not log them, since they could occur from builtin instrumentation.

Closes #400 

Patch:
diff --git a/lib/new_relic/util.ex b/lib/new_relic/util.ex
index a34a02a..3534949 100644
--- a/lib/new_relic/util.ex
+++ b/lib/new_relic/util.ex
@@ -78,7 +78,7 @@ defmodule NewRelic.Util do
       {key, value} when is_bitstring(value) ->
         case String.valid?(value) do
           true -> [{key, value}]
-          false -> [bad_value(key, value)]
+          false -> [{key, "[BINARY_VALUE]"}]
         end
 
       {key, value} when is_reference(value) when is_pid(value) when is_port(value) ->


Test patch:
diff --git a/test/transaction_test.exs b/test/transaction_test.exs
index e7effef..4e703ea 100644
--- a/test/transaction_test.exs
+++ b/test/transaction_test.exs
@@ -207,7 +207,6 @@ defmodule TransactionTest do
            end)
   end
 
-  @bad "[BAD_VALUE]"
   test "Attribute coercion" do
     TestHelper.restart_harvest_cycle(Collector.TransactionEvent.HarvestCycle)
 
@@ -233,11 +232,13 @@ defmodule TransactionTest do
     assert {:ok, _} = Date.from_iso8601(event[:date])
     assert {:ok, _} = Time.from_iso8601(event[:time])
 
+    # Binary values
+    assert event[:binary] == "[BINARY_VALUE]"
+
     # Bad values
-    assert event[:binary] == @bad
-    assert event[:tuple] == @bad
-    assert event[:function] == @bad
-    assert event[:struct] == @bad
+    assert event[:tuple] == "[BAD_VALUE]"
+    assert event[:function] == "[BAD_VALUE]"
+    assert event[:struct] == "[BAD_VALUE]"
 
     # Don't report nil values
     refute Map.has_key?(event, :nilValue)