{"record":{"id":"a655589a9159ed57","repo":"JanDeDobbeleer/oh-my-posh","slug":"invalid-docker-ps-output-on-line-d-expected-7-fi","errorCode":null,"errorMessage":"invalid docker ps output on line %d: expected 7 fields, got %d","messagePattern":"invalid docker ps output on line (.+?): expected 7 fields, got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/segments/docker.go","lineNumber":203,"sourceCode":"\n\toutput, err := d.env.RunCommand(d.command.executable, d.command.args...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlines := strings.Split(strings.TrimSpace(output), \"\\n\")\n\tif len(lines) == 0 || (len(lines) == 1 && lines[0] == \"\") {\n\t\treturn nil, nil\n\t}\n\n\tcontainers := make([]Container, 0, len(lines))\n\n\tfor i, line := range lines {\n\t\tline = strings.TrimRight(line, \"\\r\")\n\t\tfields := strings.Split(line, \"\\t\")\n\n\t\tif len(fields) != 7 {\n\t\t\treturn nil, fmt.Errorf(\"invalid docker ps output on line %d: expected 7 fields, got %d\", i+1, len(fields))\n\t\t}\n\n\t\tcontainers = append(containers, Container{\n\t\t\tID:      fields[0],\n\t\t\tImage:   fields[1],\n\t\t\tCommand: fields[2],\n\t\t\tCreated: fields[3],\n\t\t\tStatus:  fields[4],\n\t\t\tPorts:   fields[5],\n\t\t\tNames:   fields[6],\n\t\t})\n\t}\n\n\treturn containers, nil\n}\n","sourceCodeStart":185,"sourceCodeEnd":219,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/segments/docker.go#L185-L219","documentation":"The docker segment runs \"docker ps --format ...\" with tab-separated output and expects exactly 7 fields per line. If any non-empty line splits into a different number of tab-separated fields, the output can't be mapped onto the Container struct and this error aborts the segment.","triggerScenarios":"The docker CLI output doesn't match the expected tab-separated 7-column format - typically because the installed docker version doesn't support the --format used, docker prints a warning/error line to stdout, or a container name/image contains characters altering the split.","commonSituations":"Very old or very new docker/podman versions changing default output; docker daemon warnings interleaved with data; localization or a wrapper script (alias) modifying output; line ending issues (the code trims \\r but extra whitespace can remain).","solutions":["Check `docker ps --format '<the format the segment uses>'` manually - verify each line has exactly 7 tab-separated columns.","Update (or check the version of) the docker CLI - mismatched --format support is the usual culprit.","Ensure no shell alias/wrapper redefines docker ps with different output for the user running oh-my-posh.","Look at the actual first failing line number in the error to see the offending output and adapt the format."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-check docker output shape before consuming it\nout, err := exec.Command(\"docker\", \"ps\", \"--format\", formatStr).Output()\nif err == nil {\n    for i, line := range strings.Split(strings.TrimSpace(string(out)), \"\\n\") {\n        if line != \"\" && len(strings.Split(strings.TrimRight(line, \"\\r\"), \"\\t\")) != 7 {\n            log.Printf(\"docker output shape mismatch at line %d\", i+1)\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"containers, err := dockerSegment.FetchContainers()\nif err != nil && strings.Contains(err.Error(), \"invalid docker ps output\") {\n    // hide docker segment instead of failing the prompt\n    return nil\n}","preventionTips":["Keep the docker CLI version compatible with the --format the segment uses","Run `docker ps` manually with the segment's format to verify 7 tab-separated fields","Remove shell aliases/wrappers that alter docker ps output for the shell user","Update docker Desktop/CLI when upgrading oh-my-posh"],"tags":["docker","parsing","cli-output","segments"],"backgroundTag":"unexpected-cli-output-format","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}