From 4cd96e128a3f50fa9826f140dab87a460af11162 Mon Sep 17 00:00:00 2001 From: dehort Date: Fri, 19 Jan 2024 22:24:55 -0600 Subject: [PATCH] Remove extra query parameter name when calling sources using the generated code (#323) * Remove extra query parameter name when calling sources using the generated code --- internal/api/connectors/sources/impl.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/internal/api/connectors/sources/impl.go b/internal/api/connectors/sources/impl.go index dc833a87..d07767b1 100644 --- a/internal/api/connectors/sources/impl.go +++ b/internal/api/connectors/sources/impl.go @@ -4,8 +4,10 @@ import ( "context" "fmt" "net/http" + "net/url" "playbook-dispatcher/internal/common/constants" "playbook-dispatcher/internal/common/utils" + "strings" "time" "github.com/redhatinsights/platform-go-middlewares/request_id" @@ -33,6 +35,21 @@ func NewSourcesClientWithHttpRequestDoer(cfg *viper.Viper, doer HttpRequestDoer) req.Header.Set(constants.HeaderIdentity, identity) } + originalUrl := req.URL.String() + if strings.Contains(originalUrl, "filter=filter[") { + // Remove the extra filter parameter name + correctedUrl := strings.Replace(req.URL.String(), "filter=", "", -1) + + newUrl, err := url.Parse(correctedUrl) + if err != nil { + return err + } + + req.URL = newUrl + } + + fmt.Println("sources url:", req.URL) + return nil }, },