Merge pull request #3172 from chengzhichao-xydt/codex/close-error-checks-clean

fix: explicitly ignore Close() errors in error paths and retry loops
This commit is contained in:
Mauro 2026-06-26 08:41:31 +02:00 committed by GitHub
commit 124c529bf1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 9 deletions

View file

@ -569,7 +569,7 @@ func (t *ExecTool) runBackground(ctx context.Context, command, cwd string, ptyEn
// with synchronous exec runs.
if err := isolation.Start(cmd); err != nil {
if session.ptyMaster != nil {
session.ptyMaster.Close()
_ = session.ptyMaster.Close()
}
return ErrorResult(fmt.Sprintf("failed to start command: %v", err))
}
@ -698,7 +698,7 @@ func (t *ExecTool) runBackground(ctx context.Context, command, cwd string, ptyEn
// All pipes closed, get exit status
if stdinWriter != nil {
stdinWriter.Close()
_ = stdinWriter.Close()
}
cmd.Wait()

View file

@ -576,16 +576,16 @@ func extractZip(archivePath, destDir string) error {
}
out, err := os.OpenFile(target, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, f.FileInfo().Mode())
if err != nil {
rc.Close()
_ = rc.Close()
return err
}
if _, err := io.Copy(out, rc); err != nil {
rc.Close()
out.Close()
_ = rc.Close()
_ = out.Close()
return err
}
if err := rc.Close(); err != nil {
out.Close()
_ = out.Close()
return fmt.Errorf("close zip entry reader: %w", err)
}
if err := out.Close(); err != nil {

View file

@ -26,7 +26,7 @@ func DoRequestWithRetry(client *http.Client, req *http.Request) (*http.Response,
for i := range maxRetries {
if i > 0 && resp != nil {
resp.Body.Close()
_ = resp.Body.Close()
}
resp, err = client.Do(req)
@ -42,7 +42,7 @@ func DoRequestWithRetry(client *http.Client, req *http.Request) (*http.Response,
if i < maxRetries-1 {
if err = sleepWithCtx(req.Context(), retryDelayForAttempt(resp, i)); err != nil {
if resp != nil {
resp.Body.Close()
_ = resp.Body.Close()
}
return nil, fmt.Errorf("failed to sleep: %w", err)
}

View file

@ -176,7 +176,7 @@ func DownloadFile(urlStr, filename string, opts DownloadOptions) string {
}
if _, err := io.Copy(out, resp.Body); err != nil {
out.Close()
_ = out.Close()
os.Remove(localPath)
logger.ErrorCF(opts.LoggerPrefix, "Failed to write file", map[string]any{
"error": err.Error(),