{"record":{"id":"efa56cb49d569fb3","repo":"SigNoz/signoz","slug":"couldn-t-scan-metric-status-row-w","errorCode":null,"errorMessage":"couldn't scan metric status row: %w","messagePattern":"couldn't scan metric status row: %w","errorType":"exception","errorClass":"model.InternalError","httpStatus":500,"severity":"error","filePath":"pkg/query-service/app/clickhouseReader/reader.go","lineNumber":3423,"sourceCode":"\t\t\t\"couldn't query clickhouse for received metrics status: %w\", err,\n\t\t))\n\t}\n\tdefer rows.Close()\n\n\tvar result *model.MetricStatus\n\n\tif rows.Next() {\n\n\t\tresult = &model.MetricStatus{}\n\t\tvar labelsJson string\n\n\t\terr := rows.Scan(\n\t\t\t&result.MetricName,\n\t\t\t&labelsJson,\n\t\t\t&result.LastReceivedTsMillis,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, model.InternalError(fmt.Errorf(\n\t\t\t\t\"couldn't scan metric status row: %w\", err,\n\t\t\t))\n\t\t}\n\n\t\terr = json.Unmarshal([]byte(labelsJson), &result.LastReceivedLabels)\n\t\tif err != nil {\n\t\t\treturn nil, model.InternalError(fmt.Errorf(\n\t\t\t\t\"couldn't unmarshal metric labels json: %w\", err,\n\t\t\t))\n\t\t}\n\t}\n\n\treturn result, nil\n}\n\nfunc isColumn(tableStatement, attrType, field, datType string) bool {\n\tname := fmt.Sprintf(\"`%s`\", utils.GetClickhouseColumnNameV2(attrType, datType, field))\n\treturn strings.Contains(tableStatement, fmt.Sprintf(\"%s \", name))","sourceCodeStart":3405,"sourceCodeEnd":3441,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/clickhouseReader/reader.go#L3405-L3441","documentation":"Internal error from scanning a row of the metric-status query into (metric name, labels JSON, last-received timestamp millis). Indicates the result columns don't match the expected three-column shape/types, or a NULL in a non-nullable target.","triggerScenarios":"time_series table returns rows where last_received_ts or labels JSON is NULL, or column order/type changed between SigNoz versions.","commonSituations":"Schema drift after upgrade; rows written by an older ingester lacking label JSON; partial writes during ingestion incidents.","solutions":["Inspect the wrapped scan error for which column mismatched","Run the status query manually and check for NULLs in the three selected columns","Scan into sql.Null* types where NULLs are possible","Re-run migrations to align schema"],"exampleFix":"// before\n&result.LastReceivedTsMillis,\n\n// after (if ts can be NULL)\nvar ts sql.NullInt64\n... scan &ts ...\nif ts.Valid { result.LastReceivedTsMillis = ts.Int64 }","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := rows.Scan(&name, &labels, &ts); err != nil {\n    // log and skip this row instead of failing the whole request\n    continue\n}","preventionTips":["Prefer sql.Null* scans for nullable columns","Keep single ingester version writing time_series metadata"],"tags":["signoz","clickhouse","scan-error"],"backgroundTag":"row-scan-type-mismatch","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}