Skip to content

Commit

Permalink
fix error on missing high_drift
Browse files Browse the repository at this point in the history
  • Loading branch information
majewsky committed Sep 27, 2024
1 parent 3d3d746 commit b69c5f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## v2.8.0 - TBD
## v2.7.1 - TBD

Changes:
- Fix a server error being returned if the optional `high_drift` parameter is not given.

## v2.7.0 - 2024-09-10

Expand Down
14 changes: 8 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,17 @@ func handlerMetrics(w http.ResponseWriter, r *http.Request) {
if t, err := time.ParseDuration(r.URL.Query().Get("duration")); err == nil {
d = t
} else {
http.Error(w, err.Error(), http.StatusBadRequest)
http.Error(w, "while parsing duration: "+err.Error(), http.StatusBadRequest)
return
}

if u, err := time.ParseDuration(r.URL.Query().Get("high_drift")); err == nil {
hd = u
} else {
http.Error(w, err.Error(), http.StatusBadRequest)
return
if r.URL.Query().Get("high_drift") != "" {
if u, err := time.ParseDuration(r.URL.Query().Get("high_drift")); err == nil {
hd = u
} else {
http.Error(w, "while parsing high_drift: "+err.Error(), http.StatusBadRequest)
return
}
}
}

Expand Down

0 comments on commit b69c5f1

Please sign in to comment.