I get the below message on one of my flows where it goes and updates a system from another system. The weird thing is that the flow seems to fail with this error inconsistently. I have verified that the data the flow needs is there. There are times when it will fail with this message after having succeeded just a minute before with another record. I realize there could be some difference in the records but I checked the results and it has the 1 piece of data it needs to perform the update. I am at a loss as to how to even troubleshoot this .
InvalidTemplate. Unable to process template language expressions in action 'Update_Samsara_Branch_Code' inputs at line '0' and column '0': 'The template language expression 'first(body('Parse_Tags')?['id'])' cannot be evaluated because property 'id' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'.
The below is the step that fails. What it does is take a list of codes that have unique ID's assigned and filters the codes to the value needed to provide the ID data to update the other system.
As you can see there are several different ID's and Codes in the input that this step filters. In this case it looked for code 004 and as you can see from the output, Code 004 was returned with ID 2938892.

The next step does a patch back to the target system -

This is where the error occurs, but makes no sense since other records have completed just fine. I have to use the "FIRST" statement because Power Automate isn't smart enough to realize there is only one record and if I don't use that statement it automatically does another Apply to each which isn't necessary and causes longer runtime and resources.
here is the full statement for the patch
first(body('Parse_Tags')?['id'])
I know someone will probably say, create a variable and reconcile the ID in the variable and use the variable to patch the other system. I can try that, but would like to know why this is failing.
Any help is appreciated - while powerautomate is decent, it's not very intuitive or helpful with errors.