Skip to main content

Notifications

Power Automate - General Discussion
Answered

Flow failing Randomly - Condition 2 fails to to BadRequest

(0) ShareShare
ReportReport
Posted on by 16

Hello, 

 

I have a set of flows that monitor an email address and saves the PDF's attached if they fit my criteria. The flows work 99% of the time but they are failing randomly. If I resubmit the flow, it always works.

 

They always fail with:

Error: Action 'Condition_2' failed

Error Details: An action failed. No dependent actions succeeded.

The dependant action is "Create File".

 

Auteri_2-1622168018755.pngAuteri_3-1622168083373.png

Auteri_4-1622168097400.png

 

Any help would be much appreciated.

Adam Auteri

 

 

 

  • Verified answer
    Auteri Profile Picture
    Auteri 16 on at
    Re: Flow failing Randomly - Condition 2 fails to to BadRequest

    Hi @NiloferA 

     

    That has worked. I have attached what we did to solve this issue in case anyone else needs it.

     

    I added a condition after the Create File step that runs if the previous step fails and used fx "

    equals(int(actionOutputs('Create_file').statusCode), 409)" is equal to "false" then added a 20 second delay and added the Create File step again.

     

    Auteri_0-1623891461112.png

     

  • NiloferA Profile Picture
    NiloferA on at
    Re: Flow failing Randomly - Condition 2 fails to to BadRequest

    Hello @Auteri ,

    I don't think there is anything you could do in the Flow to identify if there is an active running instance of the Flow, but perhaps there is one option for you.

    As per your Reply above, it seems like the Flow is running in quick succession and only the first run is required and the subsequent ones should be cancelled.

    You can do the following to implement this,

    1. After you Create File action, if there are any other actions that are executing then keep them as is and add a parallel branch immediately after Create File action
    2. In this Parallel branch, add a Terminate action and select Cancelled as the status
    3. Click on the ellipsis icon on the top right of Terminate action, and select Configure Run after
    4. Check the box that says "When Create Item Fails"

    This will not prevent the unnecessary runs but will handle the error which arises due to the immediate executions

    Let me know if you have any further questions

  • Auteri Profile Picture
    Auteri 16 on at
    Re: Flow failing Randomly - Condition 2 fails to to BadRequest

    Hello @NiloferA 

     

    I am pretty sure I have worked out the issue, the one flow is sometimes being triggered multiple times very quickly.

     

    The PDF's I am saving are called Schedules. When a Schedule is created or edited an email is sent with the PDF attachment of the Schedule. If a Schedule is created then changed in quick succession, then the system creates multiple emails, all with a PDF with the same name. This means that at times the emails will trigger the flow multiple times in quick succession. This is causing the file to be "locked" when the flow is triggered a second time.

     

    Is it possible to add something into the flow to check that it is already running, and if it is, delay the second instance of the same flow?

     

    Or maybe another option?

  • NiloferA Profile Picture
    NiloferA on at
    Re: Flow failing Randomly - Condition 2 fails to to BadRequest

    Hello @Auteri ,

    Yes this kind of issue can occur when there are multiple flows trying to perform some action on the same file or if the file is in use by some user and Flow is trying to perform some action on it.

    There are a couple of things you can do

    1. You can add some delay in one of your flows, lets say you added a minute's delay in Flow B, then Flow A will go ahead with it's execution and Flow B will be in a paused state during that time and also please make sure that both the Flows A & B only try to create the File if it does not exist. Please refer below post for some insights on how to check if a file exists in SharePoint
      1. https://powerusers.microsoft.com/t5/General-Power-Automate/How-to-check-if-a-file-exists-in-a-SharePoint-library-by-file/td-p/338207  
    2. Or You can have another set of actions execute when your Create Item fails, you can either send an email to yourself to take care of such a situation manually or you can add some delay, check if the Files exists or not and Create it again only if it does not exist. Please refer below posts for some insights on error handling.
      1. https://powerusers.microsoft.com/t5/General-Power-Automate/HTTP-404-Error-Handling-Apply-To-Each/m-p/904711#M69530
      2. https://www.c-sharpcorner.com/article/error-handling-with-power-automate-ms-flow/#:~:text=In%20Power%20Automate%20this%20is,trigger%20manually%20as%20needed)%20template.
    3. Or You can set some Flags in the Item, So if Flow A is running on the item you set the Flag "Current Flow" ( a field in you SP List/Library") as Flow A. So when Flow B triggers, you can actually check this Flag and prevent it from triggering if the value of the flag is Flow A. Then when Flow A completes, you can reset it to something else. But you will have to be careful with the values you use and when each of the Flows should be triggered.

    To answer your question about if you can re trigger your Flow if it has failed, I am not aware of any such configuration currently, but as explained in point 2 above, if your actions have failed you can update some Flag in your item and have your Flow check this Flag at the time of trigger when an item is modified, and it will re trigger if the condition is satisfied (And if your current Flow Trigger is when an item/file is created or modified).

    Hope this helps! 

    Please give a Kudo if you found this helpful or Mark this Reply as a Solution if it solved your problem.

  • Auteri Profile Picture
    Auteri 16 on at
    Re: Flow failing Randomly - Condition 2 fails to to BadRequest

     Hi @NiloferA 

     

    I run multiple flows working out of the same mailbox, but each flow is triggering based on the initial text in the email as to whether it runs or not (e.g. QLD12-74, QLD21-58, QLD21-76).

     

    There are times when a flow is triggered to create the same file (E.g. for an updated PDF), but very rarely in quick succession. When the flow triggers like this it generally overwrites the existing file. 

     

    Could the issue be caused by someone accessing the file at the time that the flow runs?

     

    Is it possible to have the flow trigger again if the file creation set is fails? I have seen this asked before but I can never find an adequate response.

  • NiloferA Profile Picture
    NiloferA on at
    Re: Flow failing Randomly - Condition 2 fails to to BadRequest

    Hello @Auteri ,

    Is it possible that multiple Flows are running on the Same File?

    According to the error, the Flow is not able to open the File but it looks like the File is already created. I suspect that the File is being accessed/used my multiple Flows, whichever is working on the file first, locks the file for the other.

    Let me know if this makes any sense to you.

  • Auteri Profile Picture
    Auteri 16 on at
    Re: Flow failing Randomly - Condition 2 fails to to BadRequest

    @NiloferA 

     

    Screenshot 2021-05-31 073021.jpg

    And in text form:

    {"statusCode":400,"headers":{"Vary":"Origin","X-SharePointHealthScore":"2","X-MS-SPConnector":"1","X-SP-SERVERSTATE":"ReadOnly=0","DATASERVICEVERSION":"3.0","SPClientServiceRequestDuration":"142","SPRequestGuid":"9366166c-280c-44ca-ac56-ff534c634d6e","request-id":"9366166c-280c-44ca-ac56-ff534c634d6e","MS-CV":"bBZmkwwoykSsVv9TTGNNbg.0","Strict-Transport-Security":"max-age=31536000","X-FRAME-OPTIONS":"SAMEORIGIN","Content-Security-Policy":"frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com *.powerapps.com *.yammer.com *.officeapps.live.com *.office.com *.stream.azure-test.net *.microsoftstream.com;","MicrosoftSharePointTeamServices":"16.0.0.21312","X-Content-Type-Options":"nosniff","X-MS-InvokeApp":"1; RequireReadOnly","Timing-Allow-Origin":"*","x-ms-apihub-cached-response":"true","Cache-Control":"max-age=0, private","Date":"Wed, 26 May 2021 00:51:35 GMT","P3P":"CP=\"ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI\"","X-AspNet-Version":"4.0.30319","X-Powered-By":"ASP.NET","Content-Length":"335","Content-Type":"application/json","Expires":"Tue, 11 May 2021 00:51:36 GMT","Last-Modified":"Wed, 26 May 2021 00:51:36 GMT"},"body":{"status":400,"message":"Cannot open file \"https://arriumcloud.sharepoint.com/sites/NRGeneralSchedules/Shared Documents/QR Const - 137 - Caloundra St Central SS/Schedules/CALL_OFF_QLD21-137-137-0115.pdf\".\r\nclientRequestId: 9366166c-280c-44ca-ac56-ff534c634d6e\r\nserviceRequestId: 9366166c-280c-44ca-ac56-ff534c634d6e"}}
  • NiloferA Profile Picture
    NiloferA on at
    Re: Flow failing Randomly - Condition 2 fails to to BadRequest

    Hello @Auteri ,

    For the Create File Action when it has errored out, you have a link under Output which says "Click to download", can you please click on it and share a snap of the same,

    It may contain further error details which will help troubleshooting the issue.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,445

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,741

Leaderboard