From da7c3d1753d07392281620730fac73384425d130 Mon Sep 17 00:00:00 2001 From: Marwan Sulaiman Date: Fri, 15 Mar 2024 11:54:42 -0400 Subject: [PATCH] envknob: ensure f is not nil before using it This PR fixes a panic that I saw in the mac app where parsing the env file fails but we don't get to see the error due to the panic of using f.Name() Fixes #11425 Signed-off-by: Marwan Sulaiman --- envknob/envknob.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/envknob/envknob.go b/envknob/envknob.go index 7bc2b6c6d..e1ffaa8e8 100644 --- a/envknob/envknob.go +++ b/envknob/envknob.go @@ -492,7 +492,11 @@ func ApplyDiskConfig() (err error) { defer func() { if err != nil { // Stash away our return error for the healthcheck package to use. - applyDiskConfigErr = fmt.Errorf("error parsing %s: %w", f.Name(), err) + if f != nil { + applyDiskConfigErr = fmt.Errorf("error parsing %s: %w", f.Name(), err) + } else { + applyDiskConfigErr = fmt.Errorf("error applying disk config: %w", err) + } } }()