{"record":{"id":"01d238304f9e18c1","repo":"jaegertracing/jaeger","slug":"failed-to-parse-int-attribute-q-w","errorCode":null,"errorMessage":"failed to parse int attribute %q: %w","messagePattern":"failed to parse int attribute %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v2/clickhouse/tracestore/query_builder.go","lineNumber":275,"sourceCode":"\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\n\tcase pcommon.ValueTypeMap:\n\t\treturn typedAttributeValue{key: \"@map@\" + key, value: attr.Str(), valueType: t}, nil\n\tcase pcommon.ValueTypeSlice:\n\t\treturn typedAttributeValue{key: \"@slice@\" + key, value: attr.Str(), valueType: t}, nil\n\tdefault:\n\t\treturn typedAttributeValue{}, fmt.Errorf(\"unsupported attribute type %v for key %q\", t, key)\n\t}\n}\n\n// buildStringAttributeCondition adds a condition for string attributes by looking up their\n// actual stored type(s) and level(s) from the attribute_metadata table.\n//","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v2/clickhouse/tracestore/query_builder.go#L257-L293","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fix the stored value to a plain base-10 integer string (\"3\", not \"3.0\" or \" 42\")","Correct the key's type in attribute_metadata if the values are actually floats or strings","Update the producer to emit true integer attributes","During data migration, cast/validate numeric strings before writing them as int-typed"],"exampleFix":"// before\n{\"key\": \"http.status_code\", \"type\": \"int\", \"string_value\": \" 200 \"}\n// after\n{\"key\": \"http.status_code\", \"type\": \"int\", \"string_value\": \"200\"}","handlingStrategy":"validation","validationCode":"// validate int attribute strings before querying\nfunc validIntAttr(s string) bool {\n\t_, err := strconv.ParseInt(strings.TrimSpace(s), 10, 64)\n\treturn err == nil\n}","typeGuard":"func isIntTyped(v pcommon.Value) bool { return v.Type() == pcommon.ValueTypeInt }","tryCatchPattern":"if err != nil {\n\tif strings.Contains(err.Error(), \"failed to parse int attribute\") {\n\t\t// treat as string attribute or drop the condition and re-query\n\t}\n\treturn err\n}","preventionTips":["Store integers as base-10 strings without whitespace, signs beyond '-', or float notation","Validate int attributes at ingestion with a collector processor","Check int64 range before persisting values","Audit attribute_metadata after type-changing migrations"],"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"}