Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeleteFilters not working #903

Closed
2 tasks done
sbs2001 opened this issue May 24, 2022 · 3 comments · Fixed by #904
Closed
2 tasks done

DeleteFilters not working #903

sbs2001 opened this issue May 24, 2022 · 3 comments · Fixed by #904

Comments

@sbs2001
Copy link

sbs2001 commented May 24, 2022

Confirmation

  • My issue isn't already found on the issue tracker.
  • I have replicated my issue using the latest version of the library and it is still present.

cloudflare-go version

master

Go environment

❯ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/shivam/.cache/go-build"
GOENV="/home/shivam/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/shivam/.asdf/installs/golang/1.18.1/packages/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/shivam/.asdf/installs/golang/1.18.1/packages"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/shivam/.asdf/installs/golang/1.18.1/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/shivam/.asdf/installs/golang/1.18.1/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3986147942=/tmp/go-build -gno-record-gcc-switches"

Expected output

DeleteFilters should delete filters when there are multiple of them provided

Actual output

time="19-05-2022 22:46:10" level=fatal msg="HTTP status 400: invalid field value: 73d4d593bca54aa6a21f2dbfb261e81a,7631acc1987640f49ef3926440f07e43"

Code demonstrating the issue

func (api *API) DeleteFilters(ctx context.Context, zoneID string, filterIDs []string) error {
here all the filter ids are provided separated by commas.

However the docs https://developers.cloudflare.com/firewall/api/cf-filters/delete/#delete-multiple-filters say to provide each filter id as value to id parameter separately.

Steps to reproduce

Call `DeleteFilters1 with more than one filters.

References

crowdsecurity/cs-cloudflare-bouncer#96

@jacobbednarz
Copy link
Member

can you please show the exact Go code you are using here? the values for filter IDs should be a slice of values, not comma separated values.

@jacobbednarz
Copy link
Member

oh, do you mean the API request itself is joining them and you're getting this error? if so I can chat to the service team and see when this changed as it should still be supported like this.

@sbs2001
Copy link
Author

sbs2001 commented May 24, 2022

@jacobbednarz yes indeed. For eg doing something like

DeleteFilters(ctx, myZone, []string{"valid_filter_id_1", "valid_filter_id_1"})

would produce the error. The problem is because the go lib calls:

..../filters?id=<FILTER_ID_1>,<FILTER_ID_2>

While the API seems to expect soething like

/filters?id=<FILTER_ID_1>&id=<FILTER_ID_2>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants