{"record":{"id":"5bc67bf1592a2864","repo":"prometheus/node_exporter","slug":"invalid-line-in-meminfo-s","errorCode":null,"errorMessage":"invalid line in meminfo: %s","messagePattern":"invalid line in meminfo: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/meminfo_numa_linux.go","lineNumber":147,"sourceCode":"\t)\n\n\tfor scanner.Scan() {\n\t\tline := strings.TrimSpace(scanner.Text())\n\t\tif line == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tparts := strings.Fields(line)\n\n\t\tfv, err := strconv.ParseFloat(parts[3], 64)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid value in meminfo: %w\", err)\n\t\t}\n\t\tswitch l := len(parts); {\n\t\tcase l == 4: // no unit\n\t\tcase l == 5 && parts[4] == \"kB\": // has unit\n\t\t\tfv *= 1024\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"invalid line in meminfo: %s\", line)\n\t\t}\n\t\tmetric := strings.TrimRight(parts[2], \":\")\n\n\t\t// Active(anon) -> Active_anon\n\t\tmetric = re.ReplaceAllString(metric, \"_${1}\")\n\t\tmemInfo = append(memInfo, meminfoMetric{metric, prometheus.GaugeValue, parts[1], fv})\n\t}\n\n\treturn memInfo, scanner.Err()\n}\n\nfunc parseMemInfoNumaStat(r io.Reader, nodeNumber string) ([]meminfoMetric, error) {\n\tvar (\n\t\tnumaStat []meminfoMetric\n\t\tscanner  = bufio.NewScanner(r)\n\t)\n\n\tfor scanner.Scan() {","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/meminfo_numa_linux.go#L129-L165","documentation":"This error is returned by parseMemInfoNuma in collector/meminfo_numa_linux.go:147 when a line from a per-NUMA-node meminfo file has a field count other than 4 fields (no unit) or 5 fields with 'kB' as the unit. The switch on len(parts) rejects any other shape, so unexpected units (e.g. 'MB', 'GB') or extra/missing columns cause a full parse failure.","triggerScenarios":"parseMemInfoNuma reads a line whose word count is not 4, or is 5 but the 5th word is not exactly 'kB' — e.g. 'Node 0 MemFree: 1024 MB' or a line with an unexpected trailing column.","commonSituations":"Kernels emitting units other than kB for per-node meminfo entries; custom kernels or hypervisors adding columns; parsing hand-edited or fixture files; future kernel changes introducing new units.","solutions":["Check the failing line in /sys/devices/system/node/node*/meminfo for unexpected unit or column count","If the kernel emits a new unit (MB/GB), extend the switch to handle it and scale accordingly","Confirm kernel version; update the collector parser if sysfs format changed upstream","Rebuild with -tags nomeminfo_numa to skip this collector on unsupported platforms","Report the format upstream via a GitHub issue with the exact offending line"],"exampleFix":"// before\ncase l == 5 && parts[4] == \"kB\": // has unit\n\tfv *= 1024\ndefault:\n\treturn nil, fmt.Errorf(\"invalid line in meminfo: %s\", line)\n// after\ncase l == 5 && parts[4] == \"kB\":\n\tfv *= 1024\ncase l == 5 && parts[4] == \"MB\":\n\tfv *= 1024 * 1024\ndefault:\n\treturn nil, fmt.Errorf(\"invalid line in meminfo: %s\", line)","handlingStrategy":"validation","validationCode":"// Validate line shape before parse: expect 4 fields or 5 with kB unit\nparts := strings.Fields(line)\nif !(len(parts) == 4 || (len(parts) == 5 && parts[4] == \"kB\")) {\n\treturn fmt.Errorf(\"unsupported meminfo line shape: %q\", line)\n}","typeGuard":null,"tryCatchPattern":"_, err := parseMemInfoNuma(f)\nif err != nil {\n\tif strings.Contains(err.Error(), \"invalid line in meminfo\") {\n\t\t// fall back to non-NUMA meminfo collector or disable meminfo_numa\n\t}\n\treturn err\n}","preventionTips":["Pin node_exporter versions against tested kernel releases","Check sysfs unit changes after kernel upgrades (kB vs other units)","Keep fixtures (sys.ttar) updated when testing on new kernels","Disable meminfo_numa via build tag if your kernel emits unsupported units"],"tags":["linux","sysfs","parsing","meminfo","numa"],"backgroundTag":"invalid-argument-format","analyzedSha":"17ddd77c59ba27e1508e9f7894b1e55b44d6aed3","analyzedAt":"2026-09-07T17:54:06.211Z","contentChangedAt":"2026-09-07T17:54:06.211Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}