From 210c2cbc317f56e0cc902e4a6a40459ef04abc21 Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 5 Dec 2025 15:21:25 -0800 Subject: [PATCH] fix: Fail fast when TLS client creation fails If TLS is enabled (https.client.enabled=true) but misconfigured, fail immediately with glog.Fatalf rather than silently falling back to plain HTTP. This prevents confusing runtime errors when the filer only accepts HTTPS connections. --- weed/admin/handlers/file_browser_handlers.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/weed/admin/handlers/file_browser_handlers.go b/weed/admin/handlers/file_browser_handlers.go index 6798a7dbf..60e46fbc6 100644 --- a/weed/admin/handlers/file_browser_handlers.go +++ b/weed/admin/handlers/file_browser_handlers.go @@ -31,15 +31,11 @@ type FileBrowserHandlers struct { func NewFileBrowserHandlers(adminServer *dash.AdminServer) *FileBrowserHandlers { // Create HTTP client with TLS support from https.client configuration // The client is created without a timeout - each operation will set its own timeout + // If TLS is enabled but misconfigured, fail fast to alert the operator immediately + // rather than silently falling back to HTTP and causing confusing runtime errors httpClient, err := client.NewHttpClient(client.Client) if err != nil { - glog.Warningf("Failed to create HTTPS client for file browser, falling back to plain HTTP: %v", err) - // Create a fallback client without TLS, properly wiring the transport - transport := &http.Transport{} - httpClient = &client.HTTPClient{ - Client: &http.Client{Transport: transport}, - Transport: transport, - } + glog.Fatalf("Failed to create HTTPS client for file browser: %v", err) } return &FileBrowserHandlers{