jaegertracing/jaeger · error

failed to parse int attribute %q: %w

Error message

failed to parse int attribute %q: %w

What it means

parseStringToTypedValue returns this error when an attribute declared as pcommon.ValueTypeInt holds a string that strconv.ParseInt(_, 10, 64) rejects. Typed values backed by strings must be converted to int64 before being used in a ClickHouse query condition; a non-integer string makes the query unbuildable and the strconv.NumError is wrapped with %w.

Source

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

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)
	}
}

// buildStringAttributeCondition adds a condition for string attributes by looking up their
// actual stored type(s) and level(s) from the attribute_metadata table.
//

View on GitHub (pinned to 806f444784)

Solutions

  1. Fix the stored value to a plain base-10 integer string ("3", not "3.0" or " 42")
  2. Correct the key's type in attribute_metadata if the values are actually floats or strings
  3. Update the producer to emit true integer attributes
  4. During data migration, cast/validate numeric strings before writing them as int-typed

Example fix

// before
{"key": "http.status_code", "type": "int", "string_value": " 200 "}
// after
{"key": "http.status_code", "type": "int", "string_value": "200"}
Defensive patterns

Strategy: validation

Validate before calling

// validate int attribute strings before querying
func validIntAttr(s string) bool {
	_, err := strconv.ParseInt(strings.TrimSpace(s), 10, 64)
	return err == nil
}

Type guard

func isIntTyped(v pcommon.Value) bool { return v.Type() == pcommon.ValueTypeInt }

Try / catch

if err != nil {
	if strings.Contains(err.Error(), "failed to parse int attribute") {
		// treat as string attribute or drop the condition and re-query
	}
	return err
}

Prevention

When it happens

Trigger: A query condition on an int-typed attribute whose stored string is not a base-10 integer — e.g. "3.0", "0x1F", " 42" (leading space), "" or an out-of-range value beyond int64.

Common situations: Emitters sending float-formatted strings for integer fields ("3.0"); hex or whitespace-padded values; attribute_metadata reclassifying a key from string/double to int without data cleanup; imports from systems with looser numeric parsing.

Understand the failure class

Related errors


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