Closed
Description
Describe the bug
If you group by a facet that is a non-string type, like a number, the client is not able to deserialize into the type CIAppTestsBucketResponse.By
which is map[string]string
To Reproduce
Make this request:
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.CIAppTestsAggregateRequest{
Filter: &datadogV2.CIAppTestsQueryFilter{
From: datadog.PtrString("now-30d"),
Query: datadog.PtrString(fmt.Sprintf("@git.branch:%s @git.commit.sha:%s", branch, commit)),
To: datadog.PtrString("now"),
},
GroupBy: []datadogV2.CIAppTestsGroupBy{
{
Facet: "@test.status",
},
{
Facet: "@test.service",
},
{
Facet: "@ci.pipeline.number",
Limit: datadog.PtrInt64(1),
Sort: &datadogV2.CIAppAggregateSort{Order: datadogV2.CIAPPSORTORDER_DESCENDING.Ptr()},
},
},
Options: &datadogV2.CIAppQueryOptions{
Timezone: datadog.PtrString("UTC"),
},
Page: &datadogV2.CIAppQueryPageOptions{
Limit: datadog.PtrInt32(100),
},
}
ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewCIVisibilityTestsApi(apiClient)
resp, r, err := api.AggregateCIAppTestEvents(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CIVisibilityTestsApi.AggregateCIAppTestEvents`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `CIVisibilityTestsApi.AggregateCIAppTestEvents`:\n%s\n", responseContent)
}
resp.Data.Buckets[0].By
is empty because it has a number value (@ci.pipeline.number
) in it and the type is map[string]string
.
If I dump the raw value I get this but I'm unable to get anything from the map.
{
"by": {
"@ci.pipeline.number": 3018,
"@test.service": "e2e-tests",
"@test.status": "skip"
},
"computes": {
"c0": 36
}
}
Expected behavior
CIAppTestsBucketResponse.By
type should be map[string]interface{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment