From 752b06361322c7131080659295b922a79ef27326 Mon Sep 17 00:00:00 2001 From: Mikhail Chusavitin Date: Tue, 24 Feb 2026 17:42:49 +0300 Subject: [PATCH] Increase upload multipart limit for raw export bundles --- internal/server/handlers.go | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/internal/server/handlers.go b/internal/server/handlers.go index 52e9a72..a2700f1 100644 --- a/internal/server/handlers.go +++ b/internal/server/handlers.go @@ -14,6 +14,7 @@ import ( "path/filepath" "regexp" "sort" + "strconv" "strings" "time" @@ -46,8 +47,7 @@ func (s *Server) handleIndex(w http.ResponseWriter, r *http.Request) { } func (s *Server) handleUpload(w http.ResponseWriter, r *http.Request) { - // Max 100MB file - if err := r.ParseMultipartForm(100 << 20); err != nil { + if err := r.ParseMultipartForm(uploadMultipartMaxBytes()); err != nil { jsonError(w, "File too large", http.StatusBadRequest) return } @@ -143,6 +143,29 @@ func (s *Server) handleUpload(w http.ResponseWriter, r *http.Request) { }) } +func uploadMultipartMaxBytes() int64 { + // Large Redfish raw bundles can easily exceed 100 MiB once raw trees and logs + // are embedded. Keep the default high but bounded for a normal workstation. + const ( + defMB = 512 + minMB = 100 + maxMB = 2048 + ) + mb := defMB + if v := strings.TrimSpace(os.Getenv("LOGPILE_UPLOAD_MAX_MB")); v != "" { + if n, err := strconv.Atoi(v); err == nil { + if n < minMB { + n = minMB + } + if n > maxMB { + n = maxMB + } + mb = n + } + } + return int64(mb) << 20 +} + func (s *Server) reanalyzeRawExportPackage(pkg *RawExportPackage) (*models.AnalysisResult, string, error) { if pkg == nil { return nil, "", fmt.Errorf("empty package")