From 5c30f4a85901c84f855c562b7fe9c00174249c1e Mon Sep 17 00:00:00 2001 From: yusing Date: Sat, 31 Jan 2026 18:50:13 +0800 Subject: [PATCH] fix(health/check): validate URL port before dialing in Stream check Add port validation to return an unhealthy result with descriptive message when URL has no port specified, preventing potential dialing errors on zero port. --- internal/health/check/stream.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/health/check/stream.go b/internal/health/check/stream.go index 6f4c9a16..8ccfa915 100644 --- a/internal/health/check/stream.go +++ b/internal/health/check/stream.go @@ -12,6 +12,14 @@ import ( ) func Stream(ctx context.Context, url *url.URL, timeout time.Duration) (types.HealthCheckResult, error) { + if port := url.Port(); port == "" || port == "0" { + return types.HealthCheckResult{ + Latency: 0, + Healthy: false, + Detail: "no port specified", + }, nil + } + dialer := net.Dialer{ Timeout: timeout, FallbackDelay: -1,