#505 Error handling for non exist environment
Issue created by
zhuoyuan-liu
// Retrieve environment variable
envVar := r.PathValue("env")
if envVar == "" {
h.Inc(metricEnrollErr)
log.Println("Environment is missing")
return
}
// Get environment
env, err := h.Envs.Get(envVar)
if err != nil {
h.Inc(metricEnrollErr)
log.Printf("error getting environment %v", err)
return
}
// Check if environment accept enrolls
if !env.AcceptEnrolls {
h.Inc(metricEnrollErr)
log.Printf("environment not enrolling %v", err)
return
}
I just found that the osctrl will return the default 200 status code if the environment does not exist. It makes confusing to the client side and it's hard for client-side debugging. I would suggest adding a proper status code and error message to the requests.
jmpsec/osctrl