-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
Description
What happened?
The following code will cause a null pointer exception on the first iteration of the loop if span.TraceID
has a zero value.
Steps to reproduce
var traces []*model.Trace
var trace *model.Trace
var traceID model.TraceID
for received, err := stream.Recv(); !errors.Is(err, io.EOF); received, err = stream.Recv() {
if err != nil {
return nil, fmt.Errorf("stream error: %w", err)
}
for i, span := range received.Spans {
if span.TraceID != traceID {
trace = &model.Trace{}
traceID = span.TraceID
traces = append(traces, trace)
}
trace.Spans = append(trace.Spans, &received.Spans[i])
}
}