Skip to content

Commit b2ccb30

Browse files
committed
fix handling of null values in OpenTelemetry arrays
1 parent 4426db7 commit b2ccb30

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

app/vlinsert/opentelemetry/opentelemetry_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,12 @@ func TestPushProtobufRequest(t *testing.T) {
356356
timestampsExpected = []int64{1234}
357357
resultsExpected = `{"_msg":"[\"Zm9vIGJhcg==\"]","severity":"Unspecified"}`
358358
f(data, timestampsExpected, resultsExpected)
359+
360+
// decode null in ArrayValue
361+
data = `[{"scopeLogs":[{"logRecords":[{"timeUnixNano":1234,"body":{"arrayValue":{"values":[null,{}]}}}]}]}]`
362+
timestampsExpected = []int64{1234}
363+
resultsExpected = `{"_msg":"[null,null]","severity":"Unspecified"}`
364+
f(data, timestampsExpected, resultsExpected)
359365
}
360366

361367
var mp easyproto.MarshalerPool
@@ -430,6 +436,9 @@ type anyValue struct {
430436
}
431437

432438
func (av *anyValue) marshalProtobuf(mm *easyproto.MessageMarshaler) {
439+
if av == nil {
440+
return
441+
}
433442
switch {
434443
case av.StringValue != nil:
435444
mm.AppendString(1, *av.StringValue)

app/vlinsert/opentelemetry/pb_json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func decodeAnyValueToJSON(src []byte, a *fastjson.Arena, fb *fmtBuffer) (*fastjs
125125
return a.NewString(v), nil
126126
}
127127
}
128-
return nil, nil
128+
return a.NewNull(), nil
129129
}
130130

131131
func decodeKeyValueListToJSON(src []byte, a *fastjson.Arena, fb *fmtBuffer) (*fastjson.Value, error) {

docs/victorialogs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ according to the follosing docs:
2323

2424
* FEATURE: [OpenTelemetry data ingestion](https://docs.victoriametrics.com/victorialogs/data-ingestion/opentelemetry/): parse [`scope` inside ScopeLogs](https://github.com/open-telemetry/opentelemetry-proto/blob/a5f0eac5b802f7ae51dfe41e5116fe5548955e64/opentelemetry/proto/logs/v1/logs.proto#L72) and store it into [log fields](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model) starting with `scope.` prefix. See [#826](https://github.com/VictoriaMetrics/VictoriaLogs/issues/826).
2525

26+
* BUGFIX: [OpenTelemetry data ingestion](https://docs.victoriametrics.com/victorialogs/data-ingestion/opentelemetry/): properly handle `null` values inside arrays. Previously, such arrays could cause a panic during ingestion. See [#869](https://github.com/VictoriaMetrics/VictoriaLogs/issues/869#issuecomment-3627177567).
27+
2628
## [v1.40.0](https://github.com/VictoriaMetrics/VictoriaLogs/releases/tag/v1.40.0)
2729

2830
Released at 2025-12-05

0 commit comments

Comments
 (0)