fix: 500 on POST /api/heartbeats

This commit is contained in:
Steven Tang 2022-08-12 17:25:43 +10:00
parent 7cca0055fe
commit 4302cfcbd6
No known key found for this signature in database
GPG Key ID: C7B961512342C50E
1 changed files with 6 additions and 0 deletions

View File

@ -79,6 +79,12 @@ func (h *HeartbeatApiHandler) Post(w http.ResponseWriter, r *http.Request) {
machineName := r.Header.Get("X-Machine-Name")
for _, hb := range heartbeats {
if hb == nil {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("invalid heartbeat object"))
return
}
hb.OperatingSystem = opSys
hb.Editor = editor
hb.Machine = machineName