{"record":{"id":"19ebbc296cf68046","repo":"jesseduffield/lazydocker","slug":"stderr","errorCode":null,"errorMessage":"{stderr}","messagePattern":"\\{stderr\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/os.go","lineNumber":149,"sourceCode":"func (c *OSCommand) FileType(path string) string {\n\tfileInfo, err := os.Stat(path)\n\tif err != nil {\n\t\treturn \"other\"\n\t}\n\tif fileInfo.IsDir() {\n\t\treturn \"directory\"\n\t}\n\treturn \"file\"\n}\n\nfunc sanitisedCommandOutput(output []byte, err error) (string, error) {\n\toutputString := string(output)\n\tif err != nil {\n\t\t// errors like 'exit status 1' are not very useful so we'll create an error\n\t\t// from stderr if we got an ExitError\n\t\texitError, ok := err.(*exec.ExitError)\n\t\tif ok {\n\t\t\treturn outputString, errors.New(string(exitError.Stderr))\n\t\t}\n\t\treturn \"\", WrapError(err)\n\t}\n\treturn outputString, nil\n}\n\n// OpenFile opens a file with the given\nfunc (c *OSCommand) OpenFile(filename string) error {\n\tcommandTemplate := c.Config.UserConfig.OS.OpenCommand\n\ttemplateValues := map[string]string{\n\t\t\"filename\": c.Quote(filename),\n\t}\n\n\tcommand := utils.ResolvePlaceholderString(commandTemplate, templateValues)\n\terr := c.RunCommand(command)\n\treturn err\n}\n","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/jesseduffield/lazydocker/blob/7e7aadc2071d58031bf2daafca1fbd4093efc23f/pkg/commands/os.go#L131-L167","documentation":"This is sanitisedCommandOutput in pkg/commands/os.go: when a shell command fails with an *exec.ExitError, the raw 'exit status N' message is discarded and the command's stderr is returned as the error instead. So the literal message '{stderr}' in static analysis is really whatever the subprocess wrote to stderr — the actual failure text comes from docker, docker-compose, or whatever binary was run.","triggerScenarios":"Any OSCommand.RunCommand-style call whose subprocess exits non-zero: `docker stop` failing, `docker-compose up` failing, `docker system prune` being declined, etc. Only reached when err is an *exec.ExitError; other error types go through WrapError instead.","commonSituations":"Docker CLI reporting 'No such container', 'permission denied' on the docker socket (user not in docker group), docker-compose yaml syntax errors, or disk-full when running prune commands. The error text you see is verbatim stderr from the CLI tool.","solutions":["Read the stderr text in the message — it is the real cause; act on what the underlying CLI (docker/docker-compose) complained about.","Reproduce in a terminal: run the same docker/docker-compose command manually to see full output.","For 'permission denied' on /var/run/docker.sock: `sudo usermod -aG docker $USER` and re-login.","For compose file errors: `docker compose config` to validate the yaml."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"out, err := osCommand.RunCommand(\"docker stop \" + id)\nif err != nil {\n    // err.Error() IS the subprocess stderr; surface it verbatim to the user\n    log.WithError(err).Error(\"docker command failed\")\n}","preventionTips":["Always read the error text — it is the underlying CLI's own stderr, not a generic wrapper.","Reproduce failing docker/compose commands in a terminal for the full picture.","Validate compose files (`docker compose config`) and permissions (docker group) up front to avoid common stderr sources."],"tags":["docker","subprocess","stderr","exec","wrapper"],"backgroundTag":null,"analyzedSha":"7e7aadc2071d58031bf2daafca1fbd4093efc23f","analyzedAt":"2026-08-15T09:51:48.093Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}