{"record":{"id":"3bad60ae4dbc6cd2","repo":"jaegertracing/jaeger","slug":"unknown-encoding-type-02x-3bad60","errorCode":null,"errorMessage":"unknown encoding type: %#02x","messagePattern":"unknown encoding type: %#02x","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v1/badger/spanstore/writer.go","lineNumber":177,"sourceCode":"\n\tkey = make([]byte, 1+sizeOfTraceID+8+8)\n\tkey[0] = spanKeyPrefix\n\tpos := 1\n\tbinary.BigEndian.PutUint64(key[pos:], span.TraceID.High)\n\tpos += 8\n\tbinary.BigEndian.PutUint64(key[pos:], span.TraceID.Low)\n\tpos += 8\n\tbinary.BigEndian.PutUint64(key[pos:], startTime)\n\tpos += 8\n\tbinary.BigEndian.PutUint64(key[pos:], uint64(span.SpanID))\n\n\tswitch encodingType {\n\tcase protoEncoding:\n\t\tbb, err = proto.Marshal(span)\n\tcase jsonEncoding:\n\t\tbb, err = json.Marshal(span)\n\tdefault:\n\t\treturn nil, nil, fmt.Errorf(\"unknown encoding type: %#02x\", encodingType)\n\t}\n\n\treturn key, bb, err\n}\n","sourceCodeStart":159,"sourceCodeEnd":182,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v1/badger/spanstore/writer.go#L159-L182","documentation":"createTraceKV serializes a span for writing to Badger according to the SpanWriter's configured encodingType. If the writer was constructed with an encoding byte that is neither protoEncoding nor jsonEncoding, marshalling cannot proceed and this error is returned. It indicates a programmer/configuration error in how the SpanWriter was created, since both branches are internal constants.","triggerScenarios":"Constructing a SpanWriter with an unsupported encodingType byte and then writing spans (via createTraceEntry -> createTraceKV).","commonSituations":"Custom forks/embedding code passing an invalid encoding constant, or a refactor introducing a new encoding without updating this switch.","solutions":["Initialize the SpanWriter only with the supported encoding values (proto or json) from this package.","Search the codebase for where encodingType is assigned and fix the invalid value.","Add a validation at SpanWriter construction time to fail fast on unknown encodings.","Extend the switch in createTraceKV if a genuinely new encoding is being introduced."],"exampleFix":"// before\nw := &SpanWriter{encodingType: 0x07} // invalid\n// after\nw := NewSpanWriter(store, cache, protoEncoding, ...) // only proto/json encodings","handlingStrategy":"validation","validationCode":"func validEncoding(t byte) bool { return t == protoEncoding || t == jsonEncoding }\nif !validEncoding(w.encodingType) { return errors.New(\"SpanWriter: unsupported encodingType\") }","typeGuard":null,"tryCatchPattern":"key, bb, err := createTraceKV(span, w.encodingType, startTime)\nif err != nil {\n    return nil, fmt.Errorf(\"span serialization failed: %w\", err)\n}","preventionTips":["Validate encodingType in NewSpanWriter before accepting writes.","Use only the package's protoEncoding/jsonEncoding constants.","Add a unit test asserting every supported encoding round-trips through createTraceKV/decodeValue."],"tags":["badger","storage","serialization","configuration"],"backgroundTag":"unknown-encoding-type","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}