FLOW Error - Expression Cannot Be Evaluated As Property Doesn't Exists

While accessing the output of the previous action, you either use properties from defined populated schema or you write an expression for it. Many times it happens that the property you are trying to access is not present in the response schema of the previous action, because it was null. 

Take an example of Modern Approval action - and the comments property in it. When Approver responds to approval notification with valid comments then this property appears in action response. But when approver keep it blank, then the property doesn't appear at all. That's the reason when you try to access the comment with below expression then you might get error if its blank

outputs('Start_and_wait_for_an_approval')?['body/responses'][0]['comments']

You get error as shown below

Unable to process template language expressions in action 'Update_item_4' inputs at line '1' and column '10724': 'The template language expression 'outputs('Start_and_wait_for_an_approval_3')?['body/responses'][0]['comments']' cannot be evaluated because property 'comments' doesn't exist, available properties are 'responder, requestDate, responseDate, approverResponse'.

Instead of using the above expression, just make a small change in it and try it. Adding a ? symbol will make a big difference as it treats it as optional and handles the error if it's null.

outputs('Start_and_wait_for_an_approval')?['body/responses'][0]?['comments']

You can apply this rule/syntax anywhere in FLOW expressions, for any action output. This will really help and avoid FLOW run failures and continue the execution smoothly.

Thanks for reading, hope this helps you guys!