{"record":{"id":"a3877faa7aabafd9","repo":"vxcontrol/pentagi","slug":"file-check-exec-failed-with-exit-code-d-s","errorCode":null,"errorMessage":"file-check exec failed with exit code %d: %s","messagePattern":"file-check exec failed with exit code (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/tools.go","lineNumber":679,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create file-check exec: %w\", err)\n\t}\n\n\tresp, err := fte.docker.ContainerExecAttach(ctx, createResp.ID, client.ExecAttachOptions{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to attach file-check exec: %w\", err)\n\t}\n\toutput, readErr := io.ReadAll(resp.Reader)\n\tresp.Close()\n\tif readErr != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read file-check output: %w\", readErr)\n\t}\n\tinspect, err := fte.docker.ContainerExecInspect(ctx, createResp.ID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to inspect file-check exec: %w\", err)\n\t}\n\tif inspect.ExitCode != 0 {\n\t\treturn nil, fmt.Errorf(\"file-check exec failed with exit code %d: %s\", inspect.ExitCode, strings.TrimSpace(string(output)))\n\t}\n\n\tbyContainerPath := make(map[string]fileSyncEntry, len(entries))\n\tfor _, e := range entries {\n\t\tbyContainerPath[e.containerPath] = e\n\t}\n\n\tvar missing []fileSyncEntry\n\tfor _, line := range strings.Split(string(output), \"\\n\") {\n\t\tline = strings.TrimSpace(line)\n\t\tif line == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif e, ok := byContainerPath[line]; ok {\n\t\t\tmissing = append(missing, e)\n\t\t}\n\t}\n","sourceCodeStart":661,"sourceCodeEnd":697,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/tools.go#L661-L697","documentation":"This error reports that the file-check command executed inside the container finished with a nonzero exit code, and includes the command's captured stdout/stderr. Unlike the other file-check errors this is an application-level result: Docker worked, but the check script signaled failure (e.g. missing file, checksum mismatch, permission error).","triggerScenarios":"inspect.ExitCode != 0 after the file-check exec runs, e.g. the check shell command exits 1 because a file that should exist in the container is missing, checksums differ, or the check script itself is not executable/found (exit 127).","commonSituations":"Container filesystem diverged from the expected upload state (file deleted or modified inside sandbox); file-check script path wrong or not synced; permissions/ownership changed by commands run earlier in the flow; check command uses a shell binary not present in the image.","solutions":["Read the included command output in the error message — it states exactly why the check failed","Diff actual container state against expected entries (docker exec <container> ls -la <path>) to find the missing/changed file","Verify the file-check script was synced and is executable in the container; exit 127/126 means not found / not executable","Re-sync or re-upload the affected files and retry the flow step"],"exampleFix":"// before\nif inspect.ExitCode != 0 {\n\treturn nil, fmt.Errorf(\"file-check exec failed with exit code %d: %s\", inspect.ExitCode, strings.TrimSpace(string(output)))\n}\n// after\nif inspect.ExitCode != 0 {\n\treturn nil, fmt.Errorf(\"file-check exec failed with exit code %d: %s\", inspect.ExitCode, strings.TrimSpace(string(output)))\n}\n// fix on the caller side: surface the captured output to the agent/user instead of retrying blindly","handlingStrategy":"validation","validationCode":"// pre-validate files client-side before running the in-container check\nfor _, e := range entries {\n\tif _, err := os.Stat(e.hostPath); err != nil {\n\t\treturn fmt.Errorf(\"missing source file %s: %w\", e.hostPath, err)\n\t}\n}\n// also ensure the check command exists in the image:\n// docker exec <container> which -a sh","typeGuard":null,"tryCatchPattern":"err := runFileCheck(ctx)\nif err != nil {\n\tvar exitErr *ExitCodeError // or match on the message prefix\n\tif strings.HasPrefix(err.Error(), \"file-check exec failed with exit code\") {\n\t\t// deterministic result: surface output, do not blind-retry\n\t\treturn fmt.Errorf(\"sync verification failed, inspect container state: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Include the command output (already done) and surface it to the user/agent for diagnosis","Keep container filesystem read-only or track mutations so expected file state holds","Ensure the check script is synced and executable before running it","Pin the sandbox image so required shell/binary paths exist"],"tags":["docker","exec","exit-code","file-check"],"backgroundTag":"nonzero-exit-code","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}