fix: add missing return err in checkIfIpIsLive to prevent nil pointer panic - #990
fix: add missing return err in checkIfIpIsLive to prevent nil pointer panic#990123456wda wants to merge 1 commit into
Conversation
fix: add missing return err in checkIfIpIsLive to prevent nil pointer panic When net.ResolveTCPAddr fails in checkIfIpIsLive, the error was logged but execution continued to call server.Network() and server.String() on the nil *net.TCPAddr pointer, causing a nil pointer dereference panic. Add a return err statement after the log.Error call on line 84, matching the error-handling pattern used elsewhere in the same function (lines 89 and 93). Fixes konflux-ci#985 Co-Authored-By: Claude Code <noreply@anthropic.com> @
PR Summary by QodoFix nil pointer panic on DNS resolution failure in checkIfIpIsLive
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
|
🤖 Finished Review · ✅ Success · Started 1:53 PM UTC · Completed 2:04 PM UTC |
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTo customize comments, go to the Qodo configuration screen, or learn more in the docs. |
|
Looks good to me Labels: Bug fix adding missing error return in IBM cloud provider package — minimal scope, low risk |
@
Summary
Fix a nil pointer dereference panic in
checkIfIpIsLivewhen DNS resolution fails.Problem
In
pkg/ibm/ibmz_helpers.go, the functioncheckIfIpIsLivehas a missingreturnafter a failednet.ResolveTCPAddrcall. When DNS resolution fails, the error is logged but execution continues to callserver.Network()andserver.String()on the nil*net.TCPAddr, causing a panic.Fix
Add a
return errafter thelog.Errorcall, matching the error-handling pattern used elsewhere in the same function (lines 89 and 93).Test
Added
checkIfIpIsLivetest that verifies DNS resolution failure returns an error rather than panicking. The test uses"a b c"(hostname with spaces) which causesnet.ResolveTCPAddrto fail deterministically without any network call (0ms).Verification
Fixes #985
🤖 Generated with Claude Code
@