jaegertracing/jaeger · error

failed to parse bool attribute %q: %w

Error message

failed to parse bool attribute %q: %w

What it means

This error is returned by parseStringToTypedValue in the ClickHouse tracestore query builder when an attribute whose pcommon value type is Bool holds a string value that strconv.ParseBool cannot interpret. String-typed backing storage stores attribute values as strings, so typed attributes must be round-tripped back to their declared type before being used in a query condition. A malformed string means the stored value cannot be converted to a bool, so the query cannot be built and the error is wrapped with the original parse error.

Source

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

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

View on GitHub (pinned to 806f444784)

Solutions

  1. Fix or delete the offending attribute value so its string form is a valid Go bool literal (true/false, 1/0, t/f)
  2. Check attribute_metadata and correct the recorded type for that key (it may be registered as bool while values are strings)
  3. Find the producer emitting the non-boolean representation and normalize it to a real bool attribute
  4. If the value is genuinely textual, treat it as a string attribute instead of forcing a bool type

Example fix

// before (malformed stored value)
{"key": "error", "type": "bool", "string_value": "YES"}
// after
{"key": "error", "type": "bool", "string_value": "true"}
Defensive patterns

Strategy: validation

Validate before calling

// validate bool-ish attribute values before querying
func validBoolAttr(s string) bool {
	_, err := strconv.ParseBool(s)
	return err == nil
}
if !validBoolAttr(attrValue) {
	return fmt.Errorf("attribute %q is not a parseable bool: %q", key, attrValue)
}

Type guard

func isBoolTyped(v pcommon.Value) bool { return v.Type() == pcommon.ValueTypeBool }

Try / catch

traces, err := reader.GetTraces(ctx, ids)
if err != nil {
	var wrapped error
	if errors.As(err, &wrapped) && strings.Contains(err.Error(), "failed to parse bool attribute") {
		// fall back to string-attribute query or log & skip the condition
	}
	return err
}

Prevention

When it happens

Trigger: Building a trace query with a key/value condition where the attribute metadata declares ValueTypeBool but the stored string value is not one of strconv.ParseBool's accepted forms (1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False) — e.g. "yes", "on", "" or a numeric string like "2".

Common situations: Instrumentation emitting boolean-ish attributes as raw strings ("True" with locale-cased variants, "Y/N") that later get registered as bool type; schema/type drift after a collector or SDK upgrade changed the attribute type; hand-edited or migrated data in ClickHouse whose attribute_metadata says bool but whose string column value is arbitrary.

Understand the failure class

Related errors


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