{"record":{"id":"f3264c3cb1097005","repo":"jaegertracing/jaeger","slug":"failed-to-parse-bool-attribute-q-w","errorCode":null,"errorMessage":"failed to parse bool attribute %q: %w","messagePattern":"failed to parse bool attribute %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v2/clickhouse/tracestore/query_builder.go","lineNumber":263,"sourceCode":"\t\treturn args, fmt.Errorf(\"failed to marshal slice attribute %q: %w\", key, err)\n\t}\n\treturn buildSimpleAttributeCondition(q, args, \"@slice@\"+key, pcommon.ValueTypeSlice, b), nil\n}\n\nfunc buildMapAttributeCondition(q *strings.Builder, args []any, key string, attr pcommon.Value) ([]any, error) {\n\tb, err := marshalValueForQuery(attr)\n\tif err != nil {\n\t\treturn args, fmt.Errorf(\"failed to marshal map attribute %q: %w\", key, err)\n\t}\n\treturn buildSimpleAttributeCondition(q, args, \"@map@\"+key, pcommon.ValueTypeMap, b), nil\n}\n\nfunc parseStringToTypedValue(key string, attr pcommon.Value, t pcommon.ValueType) (typedAttributeValue, error) {\n\tswitch t {\n\tcase pcommon.ValueTypeBool:\n\t\tb, parseErr := strconv.ParseBool(attr.Str())\n\t\tif parseErr != nil {\n\t\t\treturn typedAttributeValue{}, fmt.Errorf(\"failed to parse bool attribute %q: %w\", key, parseErr)\n\t\t}\n\t\treturn typedAttributeValue{key: key, value: b, valueType: t}, nil\n\tcase pcommon.ValueTypeDouble:\n\t\tf, parseErr := strconv.ParseFloat(attr.Str(), 64)\n\t\tif parseErr != nil {\n\t\t\treturn typedAttributeValue{}, fmt.Errorf(\"failed to parse double attribute %q: %w\", key, parseErr)\n\t\t}\n\t\treturn typedAttributeValue{key: key, value: f, valueType: t}, nil\n\tcase pcommon.ValueTypeInt:\n\t\ti, parseErr := strconv.ParseInt(attr.Str(), 10, 64)\n\t\tif parseErr != nil {\n\t\t\treturn typedAttributeValue{}, fmt.Errorf(\"failed to parse int attribute %q: %w\", key, parseErr)\n\t\t}\n\t\treturn typedAttributeValue{key: key, value: i, valueType: t}, nil\n\tcase pcommon.ValueTypeStr:\n\t\treturn typedAttributeValue{key: key, value: attr.Str(), valueType: t}, nil\n\tcase pcommon.ValueTypeBytes:\n\t\treturn typedAttributeValue{key: \"@bytes@\" + key, value: attr.Str(), valueType: t}, nil","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v2/clickhouse/tracestore/query_builder.go#L245-L281","documentation":"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.","triggerScenarios":"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\".","commonSituations":"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.","solutions":["Fix or delete the offending attribute value so its string form is a valid Go bool literal (true/false, 1/0, t/f)","Check attribute_metadata and correct the recorded type for that key (it may be registered as bool while values are strings)","Find the producer emitting the non-boolean representation and normalize it to a real bool attribute","If the value is genuinely textual, treat it as a string attribute instead of forcing a bool type"],"exampleFix":"// before (malformed stored value)\n{\"key\": \"error\", \"type\": \"bool\", \"string_value\": \"YES\"}\n// after\n{\"key\": \"error\", \"type\": \"bool\", \"string_value\": \"true\"}","handlingStrategy":"validation","validationCode":"// validate bool-ish attribute values before querying\nfunc validBoolAttr(s string) bool {\n\t_, err := strconv.ParseBool(s)\n\treturn err == nil\n}\nif !validBoolAttr(attrValue) {\n\treturn fmt.Errorf(\"attribute %q is not a parseable bool: %q\", key, attrValue)\n}","typeGuard":"func isBoolTyped(v pcommon.Value) bool { return v.Type() == pcommon.ValueTypeBool }","tryCatchPattern":"traces, err := reader.GetTraces(ctx, ids)\nif err != nil {\n\tvar wrapped error\n\tif errors.As(err, &wrapped) && strings.Contains(err.Error(), \"failed to parse bool attribute\") {\n\t\t// fall back to string-attribute query or log & skip the condition\n\t}\n\treturn err\n}","preventionTips":["Emit boolean attributes as real bools from instrumentation, not \"yes\"/\"no\" strings","Validate attribute types with the OTel semantic-convention registry at emit time","Add a data-quality check comparing attribute_metadata types to stored string values","Watch strconv.ParseBool's accepted literal set when generating values programmatically"],"tags":["clickhouse","attributes","type-conversion","query-builder"],"backgroundTag":"attribute-type-parse-failed","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}