From 5bdd3b9f4b9fb86d5b0c302eb80cdd9884217d35 Mon Sep 17 00:00:00 2001 From: Amine Date: Fri, 11 Oct 2024 16:13:11 -0700 Subject: [PATCH] Add conditional check before setting attributes in SetSDKSetAttributes Add a conditional check in SetSDKSetAttributes to only call SetAttributes when the attribute map is not empty. This prevents API validation errors that occur when setting an empty attribute map. --- pkg/generate/code/set_sdk.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/generate/code/set_sdk.go b/pkg/generate/code/set_sdk.go index bb2f8fc2..e2a7bc4d 100644 --- a/pkg/generate/code/set_sdk.go +++ b/pkg/generate/code/set_sdk.go @@ -729,7 +729,13 @@ func SetSDKSetAttributes( ) } } - out += fmt.Sprintf("%s%s.SetAttributes(attrMap)\n", indent, targetVarName) + out += fmt.Sprintf( + "%sif len(attrMap) > 0 {\n", indent, + ) + out += fmt.Sprintf("\t%s%s.SetAttributes(attrMap)\n", indent, targetVarName) + out += fmt.Sprintf( + "%s}\n", indent, + ) continue }