{"record":{"id":"b193fb5cab5c15ee","repo":"vxcontrol/pentagi","slug":"docker-exec-systemerr-s","errorCode":null,"errorMessage":"docker exec systemerr: %s","messagePattern":"docker exec systemerr: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/docker/client.go","lineNumber":1088,"sourceCode":"\t\t\t// dropping the tail.\n\t\t\treturn nil, fmt.Errorf(\"truncated exec stream: %w\", err)\n\t\t}\n\t\tsize := int64(binary.BigEndian.Uint32(header[4:8]))\n\t\tif size == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tswitch header[0] {\n\t\tcase 1: // stdout\n\t\t\tif _, err := io.CopyN(&stdout, r, size); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif stdout.Len() > maxStdout {\n\t\t\t\treturn nil, fmt.Errorf(\"listing output exceeded %d bytes\", maxStdout)\n\t\t\t}\n\t\tcase 3: // systemerr — a daemon-level error injected mid-stream; surface it\n\t\t\tvar msg bytes.Buffer\n\t\t\t_, _ = io.CopyN(&msg, r, size)\n\t\t\treturn nil, fmt.Errorf(\"docker exec systemerr: %s\", strings.TrimSpace(msg.String()))\n\t\tdefault: // stderr and anything else — discard\n\t\t\tif _, err := io.CopyN(io.Discard, r, size); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t}\n\treturn stdout.Bytes(), nil\n}\n\ntype statFailure struct {\n\tname string\n\terr  error\n}\n\n// statContainerEntries stats every name concurrently, bounded to `workers`\n// in-flight calls. A per-entry stat error never aborts the batch: the successful\n// stats and the failures are both returned (in input order) so the caller can\n// serve a partial listing rather than discarding everything on one bad entry.","sourceCodeStart":1070,"sourceCodeEnd":1106,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/docker/client.go#L1070-L1106","documentation":"Docker's multiplexed exec stream can carry a systemerr frame (stream id 3) containing a daemon-level error message injected mid-stream. demuxExecStdout surfaces that message verbatim (trimmed) as an error, since it indicates the daemon itself reported a problem with the exec, not command output.","triggerScenarios":"The Docker daemon injects a systemerr frame, e.g. the container was stopped/removed while the exec was running, the exec process was killed by the daemon, or the daemon hit an internal error streaming the exec.","commonSituations":"Container stopped or restarted by an orchestrator (docker restart policy, compose down) during the listing; host under memory pressure killing the exec; daemon upgrades/restarts mid-stream.","solutions":["Read the daemon message embedded in the error — it usually names the concrete problem (e.g. 'container is not running')","Verify the container remained running for the whole listing and retry on a live container","Check daemon logs (`journalctl -u docker`) for the corresponding internal error","Prevent concurrent restarts/removals of the container while listings are in flight"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"state, err := dc.ContainerInspect(ctx, containerID)\nif err != nil || !state.State.Running {\n    return fmt.Errorf(\"container must be running before listing\")\n}","typeGuard":null,"tryCatchPattern":"listing, err := client.ListContainerDir(ctx, containerID, dir)\nif err != nil {\n    if msg, ok := extractSystemerrMessage(err); ok {\n        log.Printf(\"docker daemon reported: %s\", msg)\n        return retryAfterContainerCheck(ctx, containerID, dir)\n    }\n    return err\n}","preventionTips":["Keep containers running for the duration of introspection","Check daemon logs when systemerr messages recur","Avoid orchestrator restarts racing with exec-based operations","Monitor host memory pressure to prevent daemon kills"],"tags":["docker","daemon","systemerr","stream"],"backgroundTag":"docker-daemon-error","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}