Setting attributes on Figma Nodes gives console error the very first time

I am seeing a very interesting behavior when applying an attribute to any figma node using my plugin. When I try to set an attribute for a figma node for the very first time, I get the following error- "“Cannot read properties of undefined (reading ‘Buffer’)”

It fails to properly apply the style the first time but any subsequent calls to set the attribute don’t give the same error and everything works properly.

I have seen it happen when changing color of a figma rectangle node and changing text size, line height or weight of text node.

When changing color of the figma rectangle node, this is the error i get the very first time-

PLUGIN: error: “Cannot read properties of undefined (reading ‘Buffer’)”
PLUGIN: error: “FigmaNode::attrib: key: fills.0.color, value: [object Object], name: Rectangle type: RECTANGLE”

Unfortunately, I am not able to share more code because of security reasons but any suggestions or advice is greatly appreciated. Thank you in advance!