{"record":{"id":"5399981b95626ff6","repo":"containerd/containerd","slug":"failed-to-parse-line-q-w","errorCode":null,"errorMessage":"failed to parse line %q: %w","messagePattern":"failed to parse line %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/snapshots/devmapper/dmsetup/dmsetup.go","lineNumber":261,"sourceCode":"\n\tfor i, line := range lines {\n\t\tvar (\n\t\t\tattr = \"\"\n\t\t\tinfo = &DeviceInfo{}\n\t\t)\n\n\t\t_, err := fmt.Sscan(line,\n\t\t\t&info.Name,\n\t\t\t&info.BlockDeviceName,\n\t\t\t&attr,\n\t\t\t&info.Major,\n\t\t\t&info.Minor,\n\t\t\t&info.OpenCount,\n\t\t\t&info.TargetCount,\n\t\t\t&info.EventNumber)\n\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse line %q: %w\", line, err)\n\t\t}\n\n\t\t// Parse attributes (see \"man 8 dmsetup\" for details)\n\t\tinfo.Suspended = strings.Contains(attr, \"s\")\n\t\tinfo.ReadOnly = strings.Contains(attr, \"r\")\n\t\tinfo.TableLive = strings.Contains(attr, \"L\")\n\t\tinfo.TableInactive = strings.Contains(attr, \"I\")\n\n\t\tdevices[i] = info\n\t}\n\n\treturn devices, nil\n}\n\n// Version returns \"dmsetup version\" output\nfunc Version() (string, error) {\n\treturn dmsetup(\"version\")\n}","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/containerd/containerd/blob/4246446a2bf7d03837b0244118d858799393bd80/plugins/snapshots/devmapper/dmsetup/dmsetup.go#L243-L279","documentation":"Info() runs `dmsetup info` and parses each output line with fmt.Sscanf into an Info struct (name, major/minor, open/target counts, event number). This error means a line of dmsetup output did not match the expected field layout, so device info could not be produced.","triggerScenarios":"Calling Info, IsActivated, NewPoolDevice, or isInUse when dmsetup emits an unexpected line — e.g. an error/warning message, a localized or differently formatted line, or empty/garbage output from a mismatched dmsetup version.","commonSituations":"dmsetup not installed or wrong version producing different column formats; device-mapper kernel module issues causing dmsetup to print errors instead of info rows; parsing stderr mixed into stdout.","solutions":["Run `dmsetup info <device>` manually and compare output to the format string Info() expects.","Ensure dmsetup (device-mapper package) is installed and at a compatible version.","Check that only stdout is parsed — stderr noise should be captured separately by the exec helper.","Inspect the wrapped %w cause to see which field conversion failed.","Verify the kernel device-mapper module is loaded (lsmod | grep dm_mod)."],"exampleFix":"// before\ncmd := exec.Command(\"dmsetup\", \"info\") // wrong binary path prints shell error into output\n// after\nout, err := exec.Command(\"/usr/sbin/dmsetup\", \"info\").Output()\nif err != nil { return fmt.Errorf(\"dmsetup info: %w: %s\", err, out) }","handlingStrategy":"try-catch","validationCode":"func dmsetupAvailable() error {\n    if _, err := exec.LookPath(\"dmsetup\"); err != nil {\n        return fmt.Errorf(\"dmsetup not installed: %w\", err)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"info, err := devInfo(name)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to parse line\") {\n        out, raw := exec.Command(\"dmsetup\", \"info\").CombinedOutput()\n        return fmt.Errorf(\"dmsetup info unparseable: %w; raw output: %s (%v)\", err, raw, out)\n    }\n    return err\n}","preventionTips":["Install the device-mapper package and pin a compatible dmsetup version","Separate stderr from stdout in dmsetup exec wrappers","Verify dm_mod is loaded before using the snapshotter","Log raw dmsetup output alongside parse errors"],"tags":["devmapper","dmsetup","parsing","exec"],"backgroundTag":"dmsetup-output-parse-failed","analyzedSha":"4246446a2bf7d03837b0244118d858799393bd80","analyzedAt":"2026-09-02T00:14:43.053Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}