Skip to content

Commit 3bc6bfe

Browse files
authored
fix: fully prevent panic in remotecfg ui (#2164)
* Fully prevent panic in remotecfg ui * Address PR feedback
1 parent cc383c1 commit 3bc6bfe

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

internal/web/api/api.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ func listComponentsHandlerRemoteCfg(host service.Host) http.HandlerFunc {
6666
return
6767
}
6868

69-
listComponentsHandlerInternal(svc.Data().(remotecfg.Data).Host, w, r)
69+
data := svc.Data().(remotecfg.Data)
70+
if data.Host == nil {
71+
http.Error(w, "remote config service startup in progress", http.StatusInternalServerError)
72+
return
73+
}
74+
listComponentsHandlerInternal(data.Host, w, r)
7075
}
7176
}
7277

@@ -108,7 +113,13 @@ func getComponentHandlerRemoteCfg(host service.Host) http.HandlerFunc {
108113
return
109114
}
110115

111-
getComponentHandlerInternal(svc.Data().(remotecfg.Data).Host, w, r)
116+
data := svc.Data().(remotecfg.Data)
117+
if data.Host == nil {
118+
http.Error(w, "remote config service startup in progress", http.StatusInternalServerError)
119+
return
120+
}
121+
122+
getComponentHandlerInternal(data.Host, w, r)
112123
}
113124
}
114125

0 commit comments

Comments
 (0)