Skip to content

Commit b9d5586

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 <malthe@grundtvigsvej.dk>
1 parent b7251a9 commit b9d5586

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
@@ -77,7 +77,8 @@ func newForwardingHandler(
7777
hasFailover := httpso.Spec.ColdStartTimeoutFailoverRef != nil
7878

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

0 commit comments

Comments
 (0)