Skip to content

Commit 846d41f

Browse files
authored
Add conditional check before setting attributes in SetSDKSetAttributes (#554)
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. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 36c2d23 commit 846d41f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/generate/code/set_sdk.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,13 @@ func SetSDKSetAttributes(
729729
)
730730
}
731731
}
732-
out += fmt.Sprintf("%s%s.SetAttributes(attrMap)\n", indent, targetVarName)
732+
out += fmt.Sprintf(
733+
"%sif len(attrMap) > 0 {\n", indent,
734+
)
735+
out += fmt.Sprintf("\t%s%s.SetAttributes(attrMap)\n", indent, targetVarName)
736+
out += fmt.Sprintf(
737+
"%s}\n", indent,
738+
)
733739
continue
734740
}
735741

0 commit comments

Comments
 (0)