From 3588aa53c8d84261ada747e49cf90629927d24ef Mon Sep 17 00:00:00 2001 From: Derek Horton Date: Fri, 19 Jan 2024 22:04:20 -0600 Subject: [PATCH 1/3] Remove extra query parameter name when calling sources using the generated code --- internal/api/connectors/sources/impl.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/api/connectors/sources/impl.go b/internal/api/connectors/sources/impl.go index dc833a87..5d9957d7 100644 --- a/internal/api/connectors/sources/impl.go +++ b/internal/api/connectors/sources/impl.go @@ -33,6 +33,19 @@ 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 + } + return nil }, }, From 2f69cb557d5d79720075c954d67a3bfa23f3cfc3 Mon Sep 17 00:00:00 2001 From: Derek Horton Date: Fri, 19 Jan 2024 22:08:59 -0600 Subject: [PATCH 2/3] Welp, I guess it needs to compile --- internal/api/connectors/sources/impl.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/api/connectors/sources/impl.go b/internal/api/connectors/sources/impl.go index 5d9957d7..24a2789d 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" From d46d2c78ac9f515c34417963800ab6dca7a36051 Mon Sep 17 00:00:00 2001 From: Derek Horton Date: Fri, 19 Jan 2024 22:10:47 -0600 Subject: [PATCH 3/3] Debug logging --- internal/api/connectors/sources/impl.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/api/connectors/sources/impl.go b/internal/api/connectors/sources/impl.go index 24a2789d..d07767b1 100644 --- a/internal/api/connectors/sources/impl.go +++ b/internal/api/connectors/sources/impl.go @@ -48,6 +48,8 @@ func NewSourcesClientWithHttpRequestDoer(cfg *viper.Viper, doer HttpRequestDoer) req.URL = newUrl } + fmt.Println("sources url:", req.URL) + return nil }, },