{"record":{"id":"a224f836ee8c8da1","repo":"abiosoft/colima","slug":"error-decoding-docker-response","errorCode":null,"errorMessage":"error decoding docker response","messagePattern":"error decoding docker response","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"daemon/process/inotify/volumes.go","lineNumber":119,"sourceCode":"\tlog.Tracef(\"found containers %+v\", containers)\n\n\t// fetch volumes\n\tvar resp []struct {\n\t\tMounts []struct {\n\t\t\tSource string `json:\"Source\"`\n\t\t} `json:\"Mounts\"`\n\t}\n\t{\n\t\targs := append([]string{}, cmdArgs...)\n\t\targs = append(args, \"inspect\")\n\t\targs = append(args, containers...)\n\n\t\tvar buf bytes.Buffer\n\t\tif err := f.guest.RunWith(nil, &buf, args...); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error inspecting containers: %w\", err)\n\t\t}\n\t\tif err := json.NewDecoder(&buf).Decode(&resp); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error decoding docker response\")\n\t\t}\n\t}\n\n\t// process and discard redundant volumes\n\tvols := []string{}\n\t{\n\t\tshouldMount := func(child string) bool {\n\t\t\t// ignore all invalid directories.\n\t\t\t// i.e. directories not within the mounted VM directories\n\t\t\tfor _, parent := range f.vmVols {\n\t\t\t\tif strings.HasPrefix(child, parent) {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\n\t\tfor _, r := range resp {","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/daemon/process/inotify/volumes.go#L101-L137","documentation":"The stdout of `<runtime> inspect` is decoded with encoding/json into a []struct{Mounts []{Source string}}. If the buffer is not valid JSON — the runtime printed warnings/errors to stdout, output was empty or truncated — decode fails and 'error decoding docker response' is returned. Note the underlying json error is discarded (no %w), so errors.Unwrap/Is cannot reach the cause; it surfaces only through the poll goroutine's log.","triggerScenarios":"runtime emitting non-JSON preamble lines on stdout (proxy notices, plugin warnings, 'permission denied' text); empty stdout on a zero-container edge path; output truncation with very many containers.","commonSituations":"docker CLI plugins or custom builds in the guest writing to stdout; older colima versions with this exact unwrapped message.","solutions":["run inspect manually in the guest and look for non-JSON lines before the array: `colima ssh -- docker ps -q | xargs docker inspect | head`","disable/reconfigure any guest docker plugin that writes to stdout","update colima — newer code wraps the decode cause, making diagnosis direct"],"exampleFix":"// before (daemon/process/inotify/volumes.go)\nreturn nil, fmt.Errorf(\"error decoding docker response\")\n\n// after — preserve the cause for diagnosis\nreturn nil, fmt.Errorf(\"error decoding docker response: %w\", err)","handlingStrategy":"try-catch","validationCode":"// validate payload shape before/while decoding\nraw := buf.Bytes()\nif len(bytes.TrimSpace(raw)) == 0 {\n    return nil, nil // nothing running: no mounts\n}\nif !bytes.HasPrefix(bytes.TrimSpace(raw), []byte(\"[\")) {\n    return nil, fmt.Errorf(\"unexpected non-JSON inspect output: %.80s\", raw)\n}","typeGuard":null,"tryCatchPattern":"if err := json.NewDecoder(&buf).Decode(&resp); err != nil {\n    return nil, fmt.Errorf(\"error decoding docker response: %w\", err) // keep the cause!\n}","preventionTips":["always wrap decode errors with %w so the json.SyntaxError/EOF is diagnosable","guard docker plugins in the guest that print to stdout","log a truncated payload excerpt on decode failure to pinpoint pollution"],"tags":["json","parsing","docker","error-wrapping"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}