{"record":{"id":"2de2f3b4dfb7989a","repo":"jaegertracing/jaeger","slug":"span-id-from-db-is-too-long-d-chars","errorCode":null,"errorMessage":"span ID from DB is too long: %d chars","messagePattern":"span ID from DB is too long: (.+?) chars","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v2/elasticsearch/tracestore/ids.go","lineNumber":38,"sourceCode":"\t\treturn pcommon.TraceID{}, fmt.Errorf(\"trace ID from DB is too long: %d chars\", len(traceIdHex))\n\t}\n\t// Left-pad with zeros to 32 hex chars to handle shorter (e.g. 64-bit) trace IDs.\n\tif len(traceIdHex) < 32 {\n\t\ttraceIdHex = strings.Repeat(\"0\", 32-len(traceIdHex)) + traceIdHex\n\t}\n\ttraceBytes, err := hex.DecodeString(traceIdHex)\n\tif err != nil {\n\t\treturn pcommon.TraceID{}, err\n\t}\n\tcopy(traceId[:], traceBytes)\n\treturn traceId, nil\n}\n\nfunc fromDbSpanId(dbSpanId dbmodel.SpanID) (pcommon.SpanID, error) {\n\tvar spanId [8]byte\n\tspanIdHex := string(dbSpanId)\n\tif len(spanIdHex) > 16 {\n\t\treturn pcommon.SpanID{}, fmt.Errorf(\"span ID from DB is too long: %d chars\", len(spanIdHex))\n\t}\n\t// Left-pad with zeros to 16 hex chars to handle shorter span IDs.\n\tif len(spanIdHex) < 16 {\n\t\tspanIdHex = strings.Repeat(\"0\", 16-len(spanIdHex)) + spanIdHex\n\t}\n\tspanIdBytes, err := hex.DecodeString(spanIdHex)\n\tif err != nil {\n\t\treturn pcommon.SpanID{}, err\n\t}\n\tcopy(spanId[:], spanIdBytes)\n\treturn spanId, nil\n}\n\nfunc getParentSpanId(dbSpan *dbmodel.Span) dbmodel.SpanID {\n\tif dbSpan.ParentSpanID != \"\" {\n\t\treturn dbSpan.ParentSpanID\n\t}\n\t// Fallback for data written before parentSpanID was populated on the write path.","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v2/elasticsearch/tracestore/ids.go#L20-L56","documentation":"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.","triggerScenarios":"Reading spans from Elasticsearch whose span_id (or span references' IDs) contain more than 16 hex characters during dbSpanToSpan or dbSpanRefsToSpanEvents conversion.","commonSituations":"Documents written with 64-bit-wide hex span IDs from a non-OTLP pipeline; manual index edits; migrations from backends with longer span identifiers.","solutions":["Find and fix/delete the Elasticsearch document with the oversized span_id","Verify writes use jaeger's span writer producing 16-hex-char span IDs","Audit for double-encoding of span IDs during migration scripts","Align jaeger reader/writer versions to the same dbmodel schema"],"exampleFix":"// before (corrupt document in ES)\n{\"span_id\": \"0123456789abcdef0123456789abcdef\"}\n// after\n{\"span_id\": \"0123456789abcdef\"}","handlingStrategy":"validation","validationCode":"if len(span.GetSpanId()) > 16 {\n    return fmt.Errorf(\"span ID exceeds 16 hex chars: %d\", len(span.GetSpanId()))\n}","typeGuard":"func isValidSpanIDHex(s string) bool {\n    return len(s) <= 16 && len(s) > 0\n}","tryCatchPattern":null,"preventionTips":["Keep span IDs 64-bit/16-hex per OTLP spec","Audit migration scripts for double-encoding","Validate documents before bulk-indexing into jaeger indices"],"tags":["storage","elasticsearch","data-corruption"],"backgroundTag":"invalid-span-id","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}