-
Notifications
You must be signed in to change notification settings - Fork 534
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
The RunSSEHandler in server/adkrest/controllers/runtime.go explicitly calls rw.WriteHeader(http.StatusOK) before streaming events. When an error occurs later and the handler returns an error, the NewErrorHandler wrapper attempts to call http.Error() which internally calls WriteHeader() again, causing:
http: superfluous response.WriteHeader call from google.golang.org/adk/server/adkrest/internal/routers.(*RuntimeAPIRouter).Routes.NewErrorHandler.func2 (handlers.go:48)
Root Cause
In runtime.go line 108:
rw.WriteHeader(http.StatusOK) // Called here first
for event, err := range resp {
if err != nil {
// Error written, handler returns...
}
}Then in handlers.go line 46-48:
if statusErr, ok := err.(statusError); ok {
http.Error(w, statusErr.Error(), statusErr.Status()) // Tries to WriteHeader again
}Suggested Fix
Remove the explicit rw.WriteHeader(http.StatusOK) call. Go's HTTP server will automatically send 200 OK on the first write.
// BEFORE (runtime.go line 108):
rw.WriteHeader(http.StatusOK)
// AFTER:
// (remove this line - first fmt.Fprintf will implicitly set 200 OK)Environment
- ADK version: v0.2.0
- Go version: 1.24
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working