jaegertracing/jaeger · error

failed to parse double attribute %q: %w

Error message

failed to parse double attribute %q: %w

What it means

parseStringToTypedValue throws this when an attribute declared as pcommon.ValueTypeDouble is stored as a string that strconv.ParseFloat cannot convert to a float64. Because string-backed storage requires conversion before the value can be bound into a ClickHouse query, an unparseable string aborts query construction and the underlying strconv error is wrapped with %w for context.

Source

Thrown at internal/storage/v2/clickhouse/tracestore/query_builder.go:269

	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)
		}
		return typedAttributeValue{key: key, value: b, valueType: t}, nil
	case pcommon.ValueTypeDouble:
		f, parseErr := strconv.ParseFloat(attr.Str(), 64)
		if parseErr != nil {
			return typedAttributeValue{}, fmt.Errorf("failed to parse double attribute %q: %w", key, parseErr)
		}
		return typedAttributeValue{key: key, value: f, valueType: t}, nil
	case pcommon.ValueTypeInt:
		i, parseErr := strconv.ParseInt(attr.Str(), 10, 64)
		if parseErr != nil {
			return typedAttributeValue{}, fmt.Errorf("failed to parse int attribute %q: %w", key, parseErr)
		}
		return typedAttributeValue{key: key, value: i, valueType: t}, nil
	case pcommon.ValueTypeStr:
		return typedAttributeValue{key: key, value: attr.Str(), valueType: t}, nil
	case pcommon.ValueTypeBytes:
		return typedAttributeValue{key: "@bytes@" + key, value: attr.Str(), valueType: t}, nil
	case pcommon.ValueTypeMap:
		return typedAttributeValue{key: "@map@" + key, value: attr.Str(), valueType: t}, nil
	case pcommon.ValueTypeSlice:
		return typedAttributeValue{key: "@slice@" + key, value: attr.Str(), valueType: t}, nil
	default:
		return typedAttributeValue{}, fmt.Errorf("unsupported attribute type %v for key %q", t, key)

View on GitHub (pinned to 806f444784)

Solutions

  1. Correct the stored string value to a valid float64 literal (use '.' as decimal separator, no units/symbols)
  2. Fix attribute_metadata so the key's declared type matches the actual stored representation
  3. Normalize the emitting instrumentations to send numeric attribute values
  4. Pre-clean data during migration/import so numeric columns contain parseable literals

Example fix

// before
{"key": "duration_ms", "type": "double", "string_value": "12.5ms"}
// after
{"key": "duration_ms", "type": "double", "string_value": "12.5"}
Defensive patterns

Strategy: validation

Validate before calling

// validate double attribute strings before querying
func validFloatAttr(s string) bool {
	_, err := strconv.ParseFloat(s, 64)
	return err == nil
}

Type guard

func isDoubleTyped(v pcommon.Value) bool { return v.Type() == pcommon.ValueTypeDouble }

Try / catch

if err != nil {
	if strings.Contains(err.Error(), "failed to parse double attribute") {
		// re-issue the query dropping the numeric condition, or coerce on write
	}
	return err
}

Prevention

When it happens

Trigger: A query condition targets an attribute whose metadata type is Double but whose stored string value is not a valid float literal — e.g. "1,5" (locale decimal comma), "12%", "", "Infinity"-style text, or a value carrying units like "3.5ms".

Common situations: Metrics-like values emitted with units or locale formatting; CSV/import pipelines writing human-formatted numbers; a type change in attribute_metadata from string to double without backfilling values; SDK upgrades that reclassify an attribute as double.

Understand the failure class

Related errors


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