Kong / go-kong

Go binding for Kong's admin API
Apache License 2.0
87 stars 41 forks source link

Deleting a non-empty Workspace fails with bad error message #461

Open mchlumsky opened 1 month ago

mchlumsky commented 1 month ago

When deleting a workspace that is not empty, the response returned is a 400 and the message in the response isn't parsed correctly.

Example: the body of the response is: {"message":{"message":"Workspace is not empty","entities":{"plugins":224,"services":2,"routes":60,"audit_requests":1}}}

Expected:

workspaceService.Delete(ctx, &workspaceName) should return an error explaining the Workspace is not empty

Actual: workspaceService.Delete(ctx, &workspaceName) returns an error that looks like this:

HTTP status 400 (message: \"<failed to parse response body: json: cannot unmarshal object into Go struct field .Message of type string>\")

Using github.com/kong/go-kong v0.55.0 with Kong Enterprise version 3.0.2.0

Extra information: I'm pretty sure the problem comes from here. The struct doesn't match the response body.