containerd/containerd · error
failed to parse output: %q
Error message
failed to parse output: %q
What it means
Status() parses `dmsetup status` output, which must contain at least 4 space-separated fields (offset, length, target type, params). This error is thrown when the output has fewer fields, meaning the status line is malformed or not a valid table status.
Source
Thrown at plugins/snapshots/devmapper/dmsetup/dmsetup.go:311
err error
status DeviceStatus
)
output, err := dmsetup("status", deviceName)
if err != nil {
return nil, err
}
status.RawOutput = output
// Status output format:
// Offset (int64)
// Length (int64)
// Target type (string)
// Params (Array of strings)
const MinParseCount = 4
parts := strings.Split(output, " ")
if len(parts) < MinParseCount {
return nil, fmt.Errorf("failed to parse output: %q", output)
}
status.Offset, err = strconv.ParseInt(parts[0], 10, 64)
if err != nil {
return nil, fmt.Errorf("failed to parse offset: %q: %w", parts[0], err)
}
status.Length, err = strconv.ParseInt(parts[1], 10, 64)
if err != nil {
return nil, fmt.Errorf("failed to parse length: %q: %w", parts[1], err)
}
status.Target = parts[2]
status.Params = parts[3:]
return &status, nil
}
View on GitHub (pinned to 4246446a2b)
Solutions
- Run `dmsetup status <name>` manually to see the actual output shape.
- Ensure the thin-pool/device is created and activated before querying status.
- Treat a missing device as a distinct case: check Info() first or handle exit codes from dmsetup.
- Confirm dmsetup version compatibility with the expected 4+-field status format.
- Check the wrapped dmsetup exec error path — stderr may explain why the output is malformed.
Example fix
// before
usage, err := pool.GetUsage() // device not activated yet
// after
info, err := devInfo() // wrap dmsetup Info
if err != nil || !info.TableLive { return nil, fmt.Errorf("device %s not active", name) }
usage, err := pool.GetUsage() Defensive patterns
Strategy: validation
Validate before calling
func ensureDeviceActive(name string) error {
out, err := exec.Command("dmsetup", "info", name).Output()
if err != nil { return err }
return nil // exists; proceed to status
}
// call ensureDeviceActive before Status/GetUsage Try / catch
usage, err := pool.GetUsage()
if err != nil {
if strings.Contains(err.Error(), "failed to parse output") {
return fmt.Errorf("device not active or status malformed; run 'dmsetup status %s' to inspect: %w", name, err)
}
return err
} Prevention
- Only query status for devices already created and activated
- Check Info()/TableLive before Status
- Handle dmsetup non-zero exit codes instead of parsing error text
- Test parser changes against known-good `dmsetup status` samples
When it happens
Trigger: Status -> GetUsage or createSnapshot receives truncated or unexpected `dmsetup status` output: device not yet activated, error line from dmsetup, or empty output passed to the parser.
Common situations: Querying a device before it is created/activated; dmsetup reporting an error state whose status line has a different shape; version mismatch changing column count.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse line %q: %w
- failed to parse offset: %q: %w
- failed to parse length: %q: %w
- failed to get block device size: %s: %w
- failed to seek on %q: %w
AI-assisted analysis of containerd/containerd@4246446a2b (2026-09-02).
Data as JSON: /api/errors/873e6cebdcc97a8c.
Report an issue: GitHub.