{"record":{"id":"c02f20bcfbeb9df5","repo":"SigNoz/signoz","slug":"error-while-scanning-metric-name-s","errorCode":null,"errorMessage":"error while scanning metric name: %s","messagePattern":"error while scanning metric name: (.+?)","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"pkg/query-service/app/clickhouseReader/reader.go","lineNumber":2994,"sourceCode":"\t\t\tsignozMetricDBName, signozTSTableNameV41Day)\n\t}\n\n\tif req.Limit != 0 {\n\t\tquery = query + fmt.Sprintf(\" LIMIT %d;\", req.Limit)\n\t}\n\n\trows, err := r.db.Query(ctx, query, fmt.Sprintf(\"%%%s%%\", req.SearchText))\n\tif err != nil {\n\t\tr.logger.Error(\"Error while querying metric names\", errorsV2.Attr(err))\n\t\treturn nil, fmt.Errorf(\"error while executing metric name query: %s\", err.Error())\n\t}\n\tdefer rows.Close()\n\n\tvar metricNames []string\n\tfor rows.Next() {\n\t\tvar name string\n\t\tif err := rows.Scan(&name); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error while scanning metric name: %s\", err.Error())\n\t\t}\n\t\tif skipSignozMetrics && strings.HasPrefix(name, \"signoz\") {\n\t\t\tcontinue\n\t\t}\n\t\tmetricNames = append(metricNames, name)\n\t}\n\n\tif len(metricNames) == 0 {\n\t\treturn &response, nil\n\t}\n\n\t// Get all metadata in one shot\n\tmetadataMap, apiError := r.GetUpdatedMetricsMetadata(ctx, orgID, metricNames...)\n\tif apiError != nil {\n\t\treturn &response, fmt.Errorf(\"error getting updated metrics metadata: %s\", apiError.Error())\n\t}\n\n\tseen := make(map[string]struct{})","sourceCodeStart":2976,"sourceCodeEnd":3012,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/clickhouseReader/reader.go#L2976-L3012","documentation":"While iterating the result rows of the metric-name query, rows.Scan(&name) failed for at least one row. This happens when the result set's column layout does not match the single string destination — usually a schema change in the underlying view/table or a driver deserialization problem for the metric name column.","triggerScenarios":"The metric names query returns columns that aren't a single string (e.g. after a table/view redefinition or a UNION with mismatched types), or the name column becomes Nullable(String)/LowCardinality the driver can't scan into plain string on some rows.","commonSituations":"Schema drift between query-service version and ClickHouse tables; partial upgrades; a view over time_series changed shape; driver version incompatibility.","solutions":["Run the logged query manually in ClickHouse and inspect the result column types","Align query-service version with the schema (upgrade both or roll both back)","Scan into a []string-compatible type like sql.NullString if nulls appear","Check clickhouse-go driver version compatibility if errors started after a dependency bump"],"exampleFix":"// before\nvar name string\nif err := rows.Scan(&name); err != nil { ... }\n\n// after\nvar name sql.NullString\nif err := rows.Scan(&name); err != nil { ... }\nif !name.Valid { continue }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// log and skip bad rows rather than aborting the whole listing\nfor rows.Next() {\n  var name sql.NullString\n  if err := rows.Scan(&name); err != nil {\n    logger.Warn(\"skipping unscannable metric row\", errorsV2.Attr(err))\n    continue\n  }\n  if name.Valid { metricNames = append(metricNames, name.String) }\n}","preventionTips":["Use sql.NullString for columns that may be NULL","Pin compatible driver and schema versions","Integration-test listings against the real schema"],"tags":["clickhouse","metrics","row-scan","schema-drift"],"backgroundTag":"row-scan-type-mismatch","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}