Skip to content

Commit 9130559

Browse files
fix(api): prevent I/O blocking in API update handler (#765)
- Replace io.Copy to stdout with io.Discard to avoid blocking in CI/test environments - Remove unused os import - Update comment to reflect new behavior
1 parent 1e41ae9 commit 9130559

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pkg/api/update/update.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/json"
66
"io"
77
"net/http"
8-
"os"
98
"strings"
109
"time"
1110

@@ -68,8 +67,8 @@ func (handle *Handler) Handle(w http.ResponseWriter, r *http.Request) {
6867
"path": r.URL.Path,
6968
}).Info("Received HTTP API update request")
7069

71-
// Log request body to stdout for debugging.
72-
_, err := io.Copy(os.Stdout, r.Body)
70+
// Discard request body to prevent I/O blocking in tests and CI environments.
71+
_, err := io.Copy(io.Discard, r.Body)
7372
if err != nil {
7473
logrus.WithError(err).Debug("Failed to read request body")
7574
http.Error(w, "Failed to read request body", http.StatusInternalServerError)

0 commit comments

Comments
 (0)