fix: log internal errors server-side, add timeout to GDPR goroutine
This commit is contained in:
@@ -73,7 +73,9 @@ func GetGDPRExportHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}()
|
||||
var result json.RawMessage
|
||||
err := db.Conn.QueryRow(context.Background(), `SELECT export_all_user_data($1)`, userID).Scan(&result)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
err := db.Conn.QueryRow(ctx, `SELECT export_all_user_data($1)`, userID).Scan(&result)
|
||||
if err != nil {
|
||||
log.Printf("GDPR export failed for user %s: %v", userID, err)
|
||||
gdprExportCacheMu.Lock()
|
||||
|
||||
@@ -36,7 +36,8 @@ func CreateGuestUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if err := validators.Validate.Struct(&req); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
log.Printf("Failed to process request: %v", err)
|
||||
http.Error(w, "Invalid request", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -71,7 +72,8 @@ func CreateGuestUserHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Validate email format
|
||||
if err := validators.ValidateEmail(req.Email); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
log.Printf("Failed to process request: %v", err)
|
||||
http.Error(w, "Invalid request", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -157,7 +159,8 @@ func CheckEmailHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if err := validators.ValidateEmail(email); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
log.Printf("Failed to process request: %v", err)
|
||||
http.Error(w, "Invalid request", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +243,8 @@ func UpdateProfileHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if err := validators.Validate.Struct(&req); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
log.Printf("Failed to process request: %v", err)
|
||||
http.Error(w, "Invalid request", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -673,7 +674,8 @@ func ChangePasswordHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if err := validators.Validate.Struct(&req); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
log.Printf("Failed to process request: %v", err)
|
||||
http.Error(w, "Invalid request", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -835,7 +837,8 @@ func AddPatchTestHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
if err := validators.Validate.Struct(&req); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
log.Printf("Failed to process request: %v", err)
|
||||
http.Error(w, "Invalid request", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1031,7 +1034,8 @@ func UploadProfilePictureHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if _, err := images.ValidateImageBytes(fileBytes); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
log.Printf("Failed to process request: %v", err)
|
||||
http.Error(w, "Invalid request", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user