I'm attempting to transform records that come from a db call (DynamoDB, if it matters), by parsing certain columns of JSON out, and creating discrete columns based on certain keys of those objects.
Would you mind sharing a sample return from your DynamoDB query that matches the correct syntax? I think you're correct that it isn't specific to the query itself.
One theory is that in some cases inside the Items array, none of your item.cart.items have a type of vehicle. That would mean in that case .find() would return undefined and undefined.id.
Could you try adding an optional chaining operator there? So:
item.cart.items.find(e => (e.type === 'vehicle'))?.id
I still feel like there should be more to the data structure that that, potentially a second item in an array of cart's that doesn't have an items key? This seems to work perfectly without the optional chaining, but all these paths full exist:
It is 100% an array. I'm looking to see if it differs at all, row to row...I'm just not seeing anything different in the first 20 rows -- they all reflect the example you posted.