Skip to content

Commit 06322d2

Browse files
committed
fix: add defensive nil check for placeholderHandler
Reorder condition checks to verify placeholder configuration before checking handler to prevent potential panics if placeholder is enabled in spec but handler is nil. Signed-off-by: malpou <[email protected]>
1 parent eec6c8c commit 06322d2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

interceptor/proxy_handlers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ func newForwardingHandler(
6363
hasFailover := httpso.Spec.ColdStartTimeoutFailoverRef != nil
6464

6565
// Check if we should serve a placeholder page
66-
if placeholderHandler != nil && httpso.Spec.PlaceholderConfig != nil && httpso.Spec.PlaceholderConfig.Enabled {
66+
// Ensure placeholderHandler is not nil to prevent panics even if placeholder is enabled in spec
67+
if httpso.Spec.PlaceholderConfig != nil && httpso.Spec.PlaceholderConfig.Enabled && placeholderHandler != nil {
6768
endpoints, err := endpointsCache.Get(httpso.GetNamespace(), httpso.Spec.ScaleTargetRef.Service)
6869
if err != nil {
6970
// Error getting endpoints cache - return 503 Service Unavailable

0 commit comments

Comments
 (0)