jaegertracing/jaeger · error
failed to marshal slice attribute %q: %w
Error message
failed to marshal slice attribute %q: %w
What it means
buildSliceAttributeCondition serializes a slice-typed attribute via marshalValueForQuery before embedding it in the SQL condition. If marshaling fails, the error is wrapped with the attribute key so the failing attribute can be identified.
Source
Thrown at internal/storage/v2/clickhouse/tracestore/query_builder.go:245
q.WriteString("OR")
appendArrayExists(q, 2, "scope", valueType)
appendNewlineAndIndent(q, 2)
q.WriteString("OR")
appendNestedArrayExists(q, 2, "events", valueType)
appendNewlineAndIndent(q, 2)
q.WriteString("OR")
appendNestedArrayExists(q, 2, "links", valueType)
return append(args, key, value, key, value, key, value, key, value, key, value)
}
func buildBytesAttributeCondition(q *strings.Builder, args []any, key string, attr pcommon.Value) []any {
return buildSimpleAttributeCondition(q, args, "@bytes@"+key, pcommon.ValueTypeBytes, base64.StdEncoding.EncodeToString(attr.Bytes().AsRaw()))
}
func buildSliceAttributeCondition(q *strings.Builder, args []any, key string, attr pcommon.Value) ([]any, error) {
b, err := marshalValueForQuery(attr)
if err != nil {
return args, fmt.Errorf("failed to marshal slice attribute %q: %w", key, err)
}
return buildSimpleAttributeCondition(q, args, "@slice@"+key, pcommon.ValueTypeSlice, b), nil
}
func buildMapAttributeCondition(q *strings.Builder, args []any, key string, attr pcommon.Value) ([]any, error) {
b, err := marshalValueForQuery(attr)
if err != nil {
return args, fmt.Errorf("failed to marshal map attribute %q: %w", key, err)
}
return buildSimpleAttributeCondition(q, args, "@map@"+key, pcommon.ValueTypeMap, b), nil
}
func parseStringToTypedValue(key string, attr pcommon.Value, t pcommon.ValueType) (typedAttributeValue, error) {
switch t {
case pcommon.ValueTypeBool:
b, parseErr := strconv.ParseBool(attr.Str())
if parseErr != nil {
return typedAttributeValue{}, fmt.Errorf("failed to parse bool attribute %q: %w", key, parseErr)View on GitHub (pinned to 806f444784)
Solutions
- Inspect the wrapped marshal error to find the unserializable element
- Normalize the slice attribute to homogeneous, supported element types before querying
- Avoid passing deeply nested slices; flatten or convert to JSON-friendly values
- Add a pre-validation step that marshals query attributes before issuing the search
Example fix
// before: slice containing a map element fails to marshal vals := pcommon.NewValueSlice(); vals.SliceVal().AppendEmpty().SetEmptyMap() // after: use flat scalar slices vals.SliceVal().AppendEmpty().SetInt(42)
Defensive patterns
Strategy: validation
Validate before calling
b, err := json.Marshal(attr.AsRaw())
if err != nil {
return fmt.Errorf("slice attribute %q is not serializable: %w", key, err)
} Type guard
func isFlatSlice(v pcommon.Value) bool {
if v.Type() != pcommon.ValueTypeSlice { return false }
ok := true
v.Slice().Range(func(_ pcommon.Value) bool {
return ok
})
for i := 0; i < v.Slice().Len(); i++ {
t := v.Slice().At(i).Type()
if t == pcommon.ValueTypeMap || t == pcommon.ValueTypeSlice {
ok = false
}
}
return ok
} Try / catch
traceIDs, err := store.FindTraceIDs(ctx, query)
if err != nil && strings.Contains(err.Error(), "failed to marshal slice attribute") {
log.Warn("unserializable slice attribute in query", "err", err)
return err
} Prevention
- Use homogeneous scalar slices in search attributes
- Flatten nested structures before building queries
- Test attribute marshaling in unit tests for all query paths
When it happens
Trigger: A query includes a slice attribute whose contents cannot be marshaled for the ClickHouse query — e.g. nested values of unsupported types inside the slice.
Common situations: Query attributes built from arbitrary OTLP payloads containing deeply nested or heterogeneous slice values; malformed pcommon.Value slices constructed programmatically.
Related errors
- failed to marshal map attribute %q: %w
- failed to parse bool attribute %q: %w
- failed to parse double attribute %q: %w
- failed to parse int attribute %q: %w
- unsupported attribute type %v for key %q
AI-assisted analysis of jaegertracing/jaeger@806f444784 (2026-09-01).
Data as JSON: /api/errors/f397b0ec145536e6.
Report an issue: GitHub.