{"record":{"id":"0ba666d55627962f","repo":"prometheus/node_exporter","slug":"could-not-parse-expected-integer-value-for-q-w","errorCode":null,"errorMessage":"could not parse expected integer value for %q: %w","messagePattern":"could not parse expected integer value for %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/zfs_linux.go","lineNumber":288,"sourceCode":"\t\t}\n\t\tif !parseLine {\n\t\t\tcontinue\n\t\t}\n\n\t\tzpoolPathElements := strings.Split(zpoolPath, \"/\")\n\t\tpathLen := len(zpoolPathElements)\n\t\tif pathLen < 2 {\n\t\t\treturn fmt.Errorf(\"zpool path did not return at least two elements\")\n\t\t}\n\t\tzpoolName := zpoolPathElements[pathLen-2]\n\t\tzpoolFile := zpoolPathElements[pathLen-1]\n\n\t\tfor i, field := range fields {\n\t\t\tkey := fmt.Sprintf(\"kstat.zfs.misc.%s.%s\", zpoolFile, field)\n\n\t\t\tvalue, err := strconv.ParseUint(line[i], 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"could not parse expected integer value for %q: %w\", key, err)\n\t\t\t}\n\t\t\thandler(zpoolName, zfsSysctl(key), value)\n\t\t}\n\t}\n\n\treturn scanner.Err()\n}\n\nfunc (c *zfsCollector) parsePoolObjsetFile(reader io.Reader, zpoolPath string, handler func(string, string, zfsSysctl, uint64)) error {\n\tscanner := bufio.NewScanner(reader)\n\n\tparseLine := false\n\tvar zpoolName, datasetName string\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tparts := strings.Fields(line)\n\n\t\tif !parseLine && len(parts) == 3 && parts[0] == \"name\" && parts[1] == \"type\" && parts[2] == \"data\" {","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/zfs_linux.go#L270-L306","documentation":"parsePoolProcfsFile walks a /proc/spl/kstat/zfs/<pool> file whose first line is a header of column names. For each row it expects every value to parse as uint64; when strconv.ParseUint fails it wraps the parse error with the fully qualified kstat key (e.g. kstat.zfs.misc.zfetch_reclaim_success.hits) so the offending metric is identified. This means the fixture/proc file contained a non-numeric token where the header declared a numeric column.","triggerScenarios":"updatePoolStats reads a zpool kstat procfs file and a field value on a data line is empty, contains a value like '-' or a float, or columns shifted so a non-numeric field aligns with a numeric header column.","commonSituations":"Corrupted or hand-edited /proc/spl/kstat/zfs fixtures in tests; running against a ZFS version that emits new non-numeric columns; misaligned columns after header/value mismatch in mock files.","solutions":["Inspect the reported kstat key's column in the procfs file/fixture and fix the non-numeric value","Verify the header line and data line have the same number of fields (no shift)","Regenerate fixtures from a real system instead of hand-editing them","Confirm the ZFS build emits uint64 values for that kstat"],"exampleFix":"// before\nvalue, err := strconv.ParseUint(line[i], 10, 64)\n// after\nvalue, err := strconv.ParseUint(strings.TrimSpace(line[i]), 10, 64)\nif err != nil {\n    return fmt.Errorf(\"could not parse expected integer value for %q: %w\", key, err)\n}","handlingStrategy":"validation","validationCode":"for i, v := range line {\n    if _, err := strconv.ParseUint(strings.TrimSpace(v), 10, 64); err != nil {\n        // skip or fix fixture row i before calling handler\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := c.parsePoolProcfsFile(f, pool, handler); err != nil {\n    var numErr *strconv.NumError\n    if errors.As(err, &numErr) {\n        c.logger.Warn(\"skipping malformed kstat value\", \"err\", err)\n        return nil\n    }\n    return err\n}","preventionTips":["Validate fixture files against the kstat header before tests","Use %w wrapping so the underlying NumError is preserved","Regenerate fixtures with make update_fixtures from a real system","Trim whitespace before parsing"],"tags":["zfs","parsing","procfs","integer"],"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"}