Describe the bug
There are two minor backend issues to clean up:
Hardcoded %v formats in server.go: The logger.Log function expects a raw message string, but in backend/cmd/server.go (lines 55 and 376), %v is passed directly into the string (e.g. logger.Log(..., "fetching config:%v")). This causes it to literally print "fetching config:%v". The :%v should simply be removed.
Missing _ = on defer in tests: The standard convention in the Headlamp backend is to suppress unhandled errors on Close() calls to satisfy linters (e.g. defer func() { _ = resp.Body.Close() }()). However, one was missed in backend/pkg/exec/exec_test.go (line 941), which is written as defer resp.Body.Close().
Expected outcome:
Remove :%v from backend/cmd/server.go.
Update line 941 in backend/pkg/exec/exec_test.go to use the standard defer func() { _ = resp.Body.Close() }().
To Reproduce
Steps to reproduce the bug:
Run the Headlamp backend locally with an invalid flag: go run ./cmd -invalid-flag
Observe the raw "fetching config:%v" string printed in the error output.
Check backend/pkg/exec/exec_test.go line 941 to see the missing defer wrapper.
Environment (please provide info about your environment):
-Installation type: Windows
Headlamp Version: main branch
Other: N/A
Are you able to fix this issue?
Yes (I will propose a PR)
Additional Context
Describe the bug
There are two minor backend issues to clean up:
Hardcoded %v formats in server.go: The logger.Log function expects a raw message string, but in backend/cmd/server.go (lines 55 and 376), %v is passed directly into the string (e.g. logger.Log(..., "fetching config:%v")). This causes it to literally print "fetching config:%v". The :%v should simply be removed.
Missing _ = on defer in tests: The standard convention in the Headlamp backend is to suppress unhandled errors on Close() calls to satisfy linters (e.g. defer func() { _ = resp.Body.Close() }()). However, one was missed in backend/pkg/exec/exec_test.go (line 941), which is written as defer resp.Body.Close().
Expected outcome:
Remove :%v from backend/cmd/server.go.
Update line 941 in backend/pkg/exec/exec_test.go to use the standard defer func() { _ = resp.Body.Close() }().
To Reproduce
Steps to reproduce the bug:
Run the Headlamp backend locally with an invalid flag: go run ./cmd -invalid-flag
Observe the raw "fetching config:%v" string printed in the error output.
Check backend/pkg/exec/exec_test.go line 941 to see the missing defer wrapper.
Environment (please provide info about your environment):
-Installation type: Windows
Headlamp Version: main branch
Other: N/A
Are you able to fix this issue?
Yes (I will propose a PR)
Additional Context