{"record":{"id":"871fb2ccf06b2ade","repo":"prometheus/node_exporter","slug":"zpool-path-did-not-return-at-least-two-elements","errorCode":null,"errorMessage":"zpool path did not return at least two elements","messagePattern":"zpool path did not return at least two elements","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/zfs_linux.go","lineNumber":278,"sourceCode":"\tvar fields []string\n\tfor scanner.Scan() {\n\t\tline := strings.Fields(scanner.Text())\n\n\t\tif !parseLine && len(line) >= 12 && line[0] == \"nread\" {\n\t\t\t//Start parsing from here.\n\t\t\tparseLine = true\n\t\t\tfields = make([]string, len(line))\n\t\t\tcopy(fields, line)\n\t\t\tcontinue\n\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","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/zfs_linux.go#L260-L296","documentation":"Validation guard in parsePoolProcfsFile: the given zpool procfs path split on \"/\" produced fewer than two elements, so the pool name (second-to-last element) and kstat file name (last element) cannot be extracted. The zpoolPath argument passed by updatePoolStats was malformed (missing the <pool>/<file> tail).","triggerScenarios":"Thrown at collector/zfs_linux.go:278 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the pool's procfs path looks like /proc/spl/kstat/zfs/<pool>/<file>; a single-element path means the caller found a bad path while walking the zfs kstat directory.","Re-scan the pool list; a pool disappearing mid-scan can produce truncated paths — retry the scrape.","Ensure /proc/spl/kstat/zfs is a real kstat directory and not a flat or odd mount."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}