fix: [AH-923]: check params before conversion to avoid printing unwanted errors (#3554)

* fix: [AH-923]: check params before conversion to print unwanted errors
main
Shivakumar Ningappa 2025-03-19 04:28:42 +00:00 committed by Harness
parent 8e925410fb
commit 9becc91abb
1 changed files with 9 additions and 3 deletions

View File

@ -36,10 +36,16 @@ func (h *Handler) GetTags(w http.ResponseWriter, r *http.Request) {
q := r.URL.Query()
lastEntry := q.Get("last")
maxEntries, err := strconv.Atoi(q.Get("n"))
if err != nil {
log.Ctx(ctx).Error().Err(err).Msgf("Failed to parse max entries %s", q.Get("n"))
var maxEntries int
n := q.Get("n")
if n == "" {
maxEntries = docker.DefaultMaximumReturnedEntries
} else {
maxEntries, err = strconv.Atoi(n)
if err != nil {
log.Ctx(ctx).Info().Err(err).Msgf("Failed to parse max entries %s", n)
maxEntries = docker.DefaultMaximumReturnedEntries
}
}
if maxEntries <= 0 {