From b2908ae325926e8f1a9a05718094c1ea6e59f604 Mon Sep 17 00:00:00 2001 From: artaasadi Date: Sat, 28 Dec 2024 16:30:06 +0100 Subject: [PATCH] fix: add default values to named queries run --- services/inventory/http_routes.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/services/inventory/http_routes.go b/services/inventory/http_routes.go index 77fae7335..41de76cb5 100644 --- a/services/inventory/http_routes.go +++ b/services/inventory/http_routes.go @@ -1157,7 +1157,19 @@ func (h *HttpHandler) RunQueryByID(ctx echo.Context) error { engine = inventoryApi.QueryEngine(engineStr) } - queryParamMap := req.QueryParams + queryParams, err := h.metadataClient.ListQueryParameters(&httpclient.Context{UserRole: api.AdminRole}) + if err != nil { + h.logger.Error("failed to get query parameters", zap.Error(err)) + return echo.NewHTTPError(http.StatusInternalServerError, "failed to get query parameters") + } + queryParamMap := make(map[string]string) + for _, qp := range queryParams.QueryParameters { + queryParamMap[qp.Key] = qp.Value + } + + for k, v := range req.QueryParams { + queryParamMap[k] = v + } queryTemplate, err := template.New("query").Parse(query) if err != nil {