Skip to content

Commit

Permalink
fix: fully prevent panic in remotecfg ui (#2164)
Browse files Browse the repository at this point in the history
* Fully prevent panic in remotecfg ui

* Address PR feedback
  • Loading branch information
dehaansa authored and ptodev committed Dec 3, 2024
1 parent ed85f2e commit c2828ec
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions internal/web/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ func listComponentsHandlerRemoteCfg(host service.Host) http.HandlerFunc {
return
}

listComponentsHandlerInternal(svc.Data().(remotecfg.Data).Host, w, r)
data := svc.Data().(remotecfg.Data)
if data.Host == nil {
http.Error(w, "remote config service startup in progress", http.StatusInternalServerError)
return
}
listComponentsHandlerInternal(data.Host, w, r)
}
}

Expand Down Expand Up @@ -108,7 +113,13 @@ func getComponentHandlerRemoteCfg(host service.Host) http.HandlerFunc {
return
}

getComponentHandlerInternal(svc.Data().(remotecfg.Data).Host, w, r)
data := svc.Data().(remotecfg.Data)
if data.Host == nil {
http.Error(w, "remote config service startup in progress", http.StatusInternalServerError)
return
}

getComponentHandlerInternal(data.Host, w, r)
}
}

Expand Down

0 comments on commit c2828ec

Please sign in to comment.