{"record":{"id":"5654bd2ff028b693","repo":"jaegertracing/jaeger","slug":"failed-to-get-attribute-metadata-w","errorCode":null,"errorMessage":"failed to get attribute metadata: %w","messagePattern":"failed to get attribute metadata: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v2/clickhouse/tracestore/query_builder.go","lineNumber":166,"sourceCode":"\t\tappendAnd(&inner, \"s.duration >= ?\")\n\t\targs = append(args, query.DurationMin.Nanoseconds())\n\t}\n\tif query.DurationMax > 0 {\n\t\tappendAnd(&inner, \"s.duration <= ?\")\n\t\targs = append(args, query.DurationMax.Nanoseconds())\n\t}\n\tif !query.StartTimeMin.IsZero() {\n\t\tappendAnd(&inner, \"s.start_time >= ?\")\n\t\targs = append(args, query.StartTimeMin)\n\t}\n\tif !query.StartTimeMax.IsZero() {\n\t\tappendAnd(&inner, \"s.start_time <= ?\")\n\t\targs = append(args, query.StartTimeMax)\n\t}\n\n\tattributeMetadata, err := r.getAttributeMetadata(ctx, query.Attributes)\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"failed to get attribute metadata: %w\", err)\n\t}\n\n\targs, err = buildAttributeConditions(&inner, args, query.Attributes, attributeMetadata)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\tinner.WriteString(\"\\nLIMIT ?\")\n\targs = append(args, limit)\n\n\t// Wrap the inner subquery with a JOIN to trace_id_timestamps\n\t// to retrieve start/end times only for the limited set of trace IDs.\n\tq := fmt.Sprintf(sql.SearchTraceIDs, indentBlock(inner.String()))\n\n\treturn q, args, nil\n}\n\nfunc buildAttributeConditions(q *strings.Builder, args []any, attributes pcommon.Map, metadata attributeMetadata) ([]any, error) {","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v2/clickhouse/tracestore/query_builder.go#L148-L184","documentation":"buildFindTraceIDsQuery wraps failures from getAttributeMetadata, which resolves which ClickHouse columns/tables hold each queried attribute. When fetching attribute metadata from the backend fails, the trace-ID search cannot build attribute conditions and this wrapped error is returned.","triggerScenarios":"FindTraceIDs is called with attribute filters while the underlying metadata lookup (typically a ClickHouse query against attribute-metadata tables) returns an error — e.g. missing table, connection failure, or permission error.","commonSituations":"Schema not initialized (migrations not run); ClickHouse credentials lacking SELECT on metadata tables; transient network partitions between the app and ClickHouse.","solutions":["Check the wrapped inner error to identify the underlying ClickHouse failure","Verify schema migrations ran and attribute metadata tables exist","Confirm the database user has SELECT privileges on those tables","Check connectivity to ClickHouse and retry transient failures"],"exampleFix":"// before: assuming tables exist\n// after: ensure schema is provisioned\n// run: jaeger storage init / apply ClickHouse migrations before starting","handlingStrategy":"retry","validationCode":"// preflight: verify metadata tables exist\nrows, err := ch.Query(ctx, \"EXISTS TABLE default.attribute_metadata\")\nif err != nil || !exists(rows) { /* run migrations first */ }","typeGuard":null,"tryCatchPattern":"traceIDs, err := store.FindTraceIDs(ctx, query)\nif err != nil && strings.Contains(err.Error(), \"failed to get attribute metadata\") {\n    if retryable(err) {\n        return retry.WithBackoff(ctx, 3, func() error {\n            _, err = store.FindTraceIDs(ctx, query)\n            return err\n        })\n    }\n    return fmt.Errorf(\"check ClickHouse schema/migrations: %w\", err)\n}","preventionTips":["Run schema migrations before deploying the reader","Grant SELECT on attribute metadata tables to the app user","Add connection health checks and backoff-retry for ClickHouse calls"],"tags":["clickhouse","metadata","network","schema"],"backgroundTag":"metadata-lookup-failed","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}