jaegertracing/jaeger · error

span ID from DB is too long: %d chars

Error message

span ID from DB is too long: %d chars

What it means

fromDbSpanId converts a stored DB span ID (hex string) into a pcommon.SpanID, which is 8 bytes. Any span ID longer than 16 hex characters cannot fit and is rejected. Like the trace-ID variant, this signals malformed data read from the backend.

Source

Thrown at internal/storage/v2/elasticsearch/tracestore/ids.go:38

		return pcommon.TraceID{}, fmt.Errorf("trace ID from DB is too long: %d chars", len(traceIdHex))
	}
	// Left-pad with zeros to 32 hex chars to handle shorter (e.g. 64-bit) trace IDs.
	if len(traceIdHex) < 32 {
		traceIdHex = strings.Repeat("0", 32-len(traceIdHex)) + traceIdHex
	}
	traceBytes, err := hex.DecodeString(traceIdHex)
	if err != nil {
		return pcommon.TraceID{}, err
	}
	copy(traceId[:], traceBytes)
	return traceId, nil
}

func fromDbSpanId(dbSpanId dbmodel.SpanID) (pcommon.SpanID, error) {
	var spanId [8]byte
	spanIdHex := string(dbSpanId)
	if len(spanIdHex) > 16 {
		return pcommon.SpanID{}, fmt.Errorf("span ID from DB is too long: %d chars", len(spanIdHex))
	}
	// Left-pad with zeros to 16 hex chars to handle shorter span IDs.
	if len(spanIdHex) < 16 {
		spanIdHex = strings.Repeat("0", 16-len(spanIdHex)) + spanIdHex
	}
	spanIdBytes, err := hex.DecodeString(spanIdHex)
	if err != nil {
		return pcommon.SpanID{}, err
	}
	copy(spanId[:], spanIdBytes)
	return spanId, nil
}

func getParentSpanId(dbSpan *dbmodel.Span) dbmodel.SpanID {
	if dbSpan.ParentSpanID != "" {
		return dbSpan.ParentSpanID
	}
	// Fallback for data written before parentSpanID was populated on the write path.

View on GitHub (pinned to 806f444784)

Solutions

  1. Find and fix/delete the Elasticsearch document with the oversized span_id
  2. Verify writes use jaeger's span writer producing 16-hex-char span IDs
  3. Audit for double-encoding of span IDs during migration scripts
  4. Align jaeger reader/writer versions to the same dbmodel schema

Example fix

// before (corrupt document in ES)
{"span_id": "0123456789abcdef0123456789abcdef"}
// after
{"span_id": "0123456789abcdef"}
Defensive patterns

Strategy: validation

Validate before calling

if len(span.GetSpanId()) > 16 {
    return fmt.Errorf("span ID exceeds 16 hex chars: %d", len(span.GetSpanId()))
}

Type guard

func isValidSpanIDHex(s string) bool {
    return len(s) <= 16 && len(s) > 0
}

Prevention

When it happens

Trigger: Reading spans from Elasticsearch whose span_id (or span references' IDs) contain more than 16 hex characters during dbSpanToSpan or dbSpanRefsToSpanEvents conversion.

Common situations: Documents written with 64-bit-wide hex span IDs from a non-OTLP pipeline; manual index edits; migrations from backends with longer span identifiers.

Related errors


AI-assisted analysis of jaegertracing/jaeger@806f444784 (2026-09-01). Data as JSON: /api/errors/2de2f3b4dfb7989a. Report an issue: GitHub.