fix: enforce request body size limits across the API

Ultraworked with Sisyphus (https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-05-31 10:55:33 +01:00
co-authored by Sisyphus
parent 700b7c1152
commit 1a6947a9b6
2 changed files with 25 additions and 6 deletions
+2 -1
View File
@@ -20,10 +20,11 @@ type SquareWebhookEvent struct {
}
func HandleSquareWebhook(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, 512*1024)
body, err := io.ReadAll(r.Body)
if err != nil {
log.Printf("Failed to read webhook body: %v", err)
http.Error(w, "Internal server error", http.StatusInternalServerError)
http.Error(w, "request body too large or unreadable", http.StatusRequestEntityTooLarge)
return
}
defer r.Body.Close()