Skip to content

Commit 876a69a

Browse files
committed
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.
1 parent 36c2d23 commit 876a69a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/generate/code/set_sdk.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,13 @@ func SetSDKSetAttributes(
729729
)
730730
}
731731
}
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+
)
732739
out += fmt.Sprintf("%s%s.SetAttributes(attrMap)\n", indent, targetVarName)
733740
continue
734741
}

0 commit comments

Comments
 (0)