go test -v ./...
? github.com/newrelic/go-agent/v3/integrations/logcontext-v2/zerologWriter/example [no test files]
=== RUN TestParseLogData
--- FAIL: TestParseLogData (0.00s)
panic: runtime error: index out of range [-1] [recovered]
panic: runtime error: index out of range [-1]
goroutine 21 [running]:
testing.tRunner.func1.2({0x10119e020, 0x140000de8a0})
/opt/homebrew/Cellar/go/1.22.5/libexec/src/testing/testing.go:1631 +0x1c4
testing.tRunner.func1()
/opt/homebrew/Cellar/go/1.22.5/libexec/src/testing/testing.go:1634 +0x33c
panic({0x10119e020?, 0x140000de8a0?})
/opt/homebrew/Cellar/go/1.22.5/libexec/src/runtime/panic.go:770 +0x124
github.com/newrelic/go-agent/v3/integrations/logcontext-v2/zerologWriter.isStringValue(...)
/Users/mario/Repositories/github.com/newrelic/go-agent/v3/integrations/logcontext-v2/zerologWriter/zerolog-writer.go:93
github.com/newrelic/go-agent/v3/integrations/logcontext-v2/zerologWriter.parseJSONLogData({0x100fc1788, 0x27, 0x27})
/Users/mario/Repositories/github.com/newrelic/go-agent/v3/integrations/logcontext-v2/zerologWriter/zerolog-writer.go:74 +0x2a8
github.com/newrelic/go-agent/v3/integrations/logcontext-v2/zerologWriter.TestParseLogData(0x140000e4d00)
/Users/mario/Repositories/github.com/newrelic/go-agent/v3/integrations/logcontext-v2/zerologWriter/zerolog-writer_test.go:147 +0x104
testing.tRunner(0x140000e4d00, 0x1011e3620)
/opt/homebrew/Cellar/go/1.22.5/libexec/src/testing/testing.go:1689 +0xec
created by testing.(*T).Run in goroutine 1
/opt/homebrew/Cellar/go/1.22.5/libexec/src/testing/testing.go:1742 +0x318
FAIL github.com/newrelic/go-agent/v3/integrations/logcontext-v2/zerologWriter 0.466s
FAIL
Description
go-agent panics when message has
,
(or a escaped"
) as the last character(s)Steps to Reproduce
The easiest way to reproduce is to use a message like the following:
Also notice the diff for the tests (listed below) has a test cases using only
,
and still panics.Expected Behavior
Does not panic
NR Diag results
This is the normal output we get when serving the app, but below there's a shorter log that uses the diff:
Your Environment
N/A
Reproduction case
Here's a diff demonstrating the issue using the existing test cases:
Log output:
Additional context
Maybe be related to: https://github.com/newrelic/go-agent/issues/583 ?