Hi everyone,
I had designed an automated flow (with Trigger action: When an Item is created {SharePoint list} (the list name is User List). In this list we are feeding the data through API call (that is done through SharePoint API endpoint wherein they pass some basic details like: EmployeeID, Experience,Designation, ReportingManagerEmail, IsActive (Yes/No) etc) once an item is created my flow gets triggered that is used to assign custom item permissions i.e. only the user and his immediate Manager and Manager's RM {if there is any} get access (basically 2 level hierarchy). The flow looks like:

In the Get Items action (In Yes block: of condition) it is used to retrieve managers details (of that particular user) and similarly to get managers RM I have another action 'Get Items Managers RM', if the user has no Manager assigned that field is empty then I am just granting only the user the access (which is in the No block of Condition-2: Check If Manager field is empty)

In the Get items Managers RM: (Used to get details of Managers RM details)
Filter Query: Fetching the Managers RM details only (that particular user managers RM)
Example:
User
Samuel Badree (is the user whose record gets created in the list) {Manager: sam@xyz.com}
Sam Lee {Manager: joe@xyz.com}
The flow gets triggered in when an item is created trigger action we get that user details like email, designation, ReportingManagerEmail, etc.
Now in 1st Grant action:
We assign access to User and his manager access (i.e. Samuel and Sam}
Now we retrieve details of Sam Lee's manager i.e. Joe (from the User List} in the 'Get items Managers RM' action
Then we are checking if the response/output from previous action is it empty or not, like for instance if Sam did not have any manager (it can be he is CEO) then in that case the previous
action wouldreturn empty and we go in no block : do nothing, but in this example as Sam does have a manager 'Joe' it (the condition will return true) and go in Yes block and give
Joe the access to Samuel's record (as he is part of Sam's team who reports to him)
In the condition I am just checking Manager's RM is not empty to avoid empty values and then flow getting failed to avoid that I have added the two condition check
Conditions:
length(outputs('Get_items_Managers_RM')?['body/value']) is greater than 0
first(body('Get_items_Managers_RM')?['value'])?['ReportingManagerEmail'] is not equal to null
So, this flow was working fine, but last week I got an automated notification email regarding this flow that there were flow runs that were failed
(which we usually get when the flow fails multiple times), so when I had a look, the flow had failed almost 20-25 times and when I checked for
the reason it was at Grant item access or file action

And when I checked the Output for the Bad request in Grant access action:
So I am not sure what was the issue, so today I created a manual flow just to check for the flow runs that were failed check if the users are present in Office365 list, so right now I have added an action Search Users from Office 365 wherein its search term I am giving it the user email as input and then in my existing condition I have added another condition group (AND group) wherein I am checking if its length is not 0 (if yes then continue with my existing flow in Yes block else do nothing)
