{"record":{"id":"707347e1702b0ab2","repo":"prometheus/node_exporter","slug":"invalid-value-in-meminfo-w","errorCode":null,"errorMessage":"invalid value in meminfo: %w","messagePattern":"invalid value in meminfo: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/meminfo_numa_linux.go","lineNumber":140,"sourceCode":"}\n\nfunc parseMemInfoNuma(r io.Reader) ([]meminfoMetric, error) {\n\tvar (\n\t\tmemInfo []meminfoMetric\n\t\tscanner = bufio.NewScanner(r)\n\t\tre      = regexp.MustCompile(`\\((.*)\\)`)\n\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","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/meminfo_numa_linux.go#L122-L158","documentation":"This error is returned by parseMemInfoNuma in collector/meminfo_numa_linux.go:140 when strconv.ParseFloat fails to parse field index 3 of a line from a per-NUMA-node /sys/devices/system/node/nodeN/meminfo file. The collector expects each line to contain a numeric value at parts[3] (the byte count); any non-numeric token there aborts the whole NUMA meminfo parse. It wraps the underlying strconv error via %w.","triggerScenarios":"parseMemInfoNuma reads a line from a node's meminfo whose 4th whitespace-separated field (parts[3]) is not a valid base-10 float, e.g. 'Node 0 MemUsed: abc kB' or a truncated/garbled line missing fields so parts[3] is actually a unit or label.","commonSituations":"Running a nonstandard or patched kernel that formats node meminfo differently; reading a fixture/test file with malformed lines; virtualized or container environments exposing a synthesized sysfs with unexpected content; kernel version changes altering the per-node meminfo layout.","solutions":["Inspect the failing /sys/devices/system/node/node*/meminfo content and check which line has a non-numeric 4th field","Verify kernel version; if the sysfs format changed, update the parser to match the new layout","Check for truncated reads or corrupted sysfs (virtualization/container artifacts) and re-read the file","Rebuild with -tags nomeminfo_numa to disable the meminfo_numa collector if the platform cannot be supported","File an issue upstream with the offending line if a supported kernel produces this format"],"exampleFix":"// before\nfv, err := strconv.ParseFloat(parts[3], 64)\nif err != nil {\n\treturn nil, fmt.Errorf(\"invalid value in meminfo: %w\", err)\n}\n// after (skip unparseable lines instead of failing the whole node)\nfv, err := strconv.ParseFloat(parts[3], 64)\nif err != nil {\n\treturn nil, fmt.Errorf(\"invalid value in meminfo: %w\", err) // keep abort, but log line context\n}","handlingStrategy":"validation","validationCode":"// Pre-validate a meminfo line before relying on parts[3]\nparts := strings.Fields(line)\nif len(parts) < 4 {\n\treturn fmt.Errorf(\"line too short: %q\", line)\n}\nif _, err := strconv.ParseFloat(parts[3], 64); err != nil {\n\treturn fmt.Errorf(\"non-numeric value in %q: %v\", line, err)\n}","typeGuard":null,"tryCatchPattern":"metrics, err := parseMemInfoNuma(f)\nif err != nil {\n\tvar perr *strconv.NumError\n\tif errors.As(err, &perr) {\n\t\t// handle malformed numeric field: log and skip node or fall back to non-NUMA meminfo\n\t}\n\treturn err\n}","preventionTips":["Run only on kernels whose per-node meminfo matches the expected 4/5-field format","Test the collector against your exact kernel version before deploying","Use the nomeminfo_numa build tag on platforms with nonstandard sysfs","Watch scrape errors on /metrics to catch format drift early"],"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"}