Azure / LogicAppsUX

https://learn.microsoft.com/azure/logic-apps
MIT License
74 stars 80 forks source link

[for each] action been added automatically when using the dynamics contents #5191

Closed ZhouYiyun001 closed 3 weeks ago

ZhouYiyun001 commented 1 month ago

Describe the Bug with repro steps

■summary of this problem

Cx is facing an issue when using Standard Logic Apps that the [for each] action will been added automatically when using the dynamics contents in the next action.

We reproduced this issue in the stateless workflow in Standard Logic Apps using blob trigger and [Get blob content using path (V2)] action.

and we find that the issue doesn't occur in stateful workflow,and consumption Logic Apps.

Action's name : Get blob content using path (V2)

https://learn.microsoft.com/en-us/connectors/azureblob/#get-blob-content-using-path-(v2)

■How to reproduce this problem

st1.Create a stateless workflow in Standard Logic Apps

st2.Add [When a blob is added or modified (properties only) (V2)] as a Trigger

st3.Add [Get blob content using path (V2)] as an action

st4.Select dynamics contents [List of File Path] as the parameter in [Get blob content using path (V2)]action, Found that [For each] action has been added automatically.

this issue not only occurs in blob action but also occurs in other actions when import dynamics contents in the parameter

What type of Logic App Is this happening in?

Standard (Portal)

Are you using new designer or old designer

New Designer

Did you refer to the TSG before filing this issue? https://aka.ms/lauxtsg

Yes

Workflow JSON

No response

Screenshots or Videos

No response

Browser

edge

Additional context

No response

ZhouYiyun001 commented 1 month ago

■How to reproduce this problem st1.Create a stateless workflow in Standard Logic Apps

st2.Add [When a blob is added or modified (properties only) (V2)] as a Trigger IMG_1516

st3.Add [Get blob content using path (V2)] as an action IMG_1518

st4.Select dynamics contents [List of File Path] as the parameter in [Get blob content using path (V2)]action, Found that [For each] action has been added automatically. this issue not only occurs in blob action but also occurs in other actions when import dynamics contents in the parameter

IMG_1519

IMG_1520 IMG_1521

ccastrotrejo commented 1 month ago

Hi @ZhouYiyun001 thanks for raising this issue. As far as I know this is the expected behavior. As the dynamic conent that you want to set as input is "The path of the file or folder", this means that is individually by file or folder, meaning that once the action get the list of files/folders it needs to iterate throught every file/folder to get the path of it. Thats the reason it adds automaticallyt the foreach action.

What its odd is that it is not doing it for stateful and consumption. I will check on those

JMTK commented 4 weeks ago

Yeah... it keeps nesting the for each every time I add any dynamic content field to my message image

hdilantha commented 3 weeks ago

Having the same issue here. Worst part is that the automatically created For each actions comes with invalid parameters.

Eric-B-Wu commented 3 weeks ago

Hi @ZhouYiyun001 thanks for raising this issue. As far as I know this is the expected behavior. As the dynamic conent that you want to set as input is "The path of the file or folder", this means that is individually by file or folder, meaning that once the action get the list of files/folders it needs to iterate throught every file/folder to get the path of it. Thats the reason it adds automaticallyt the foreach action.

What its odd is that it is not doing it for stateful and consumption. I will check on those

we should verify if this was a recent regression, think there were some implicit for each changes here: https://github.com/Azure/LogicAppsUX/pull/5149/files

ccastrotrejo commented 3 weeks ago

Hi @hdilantha, @JMTK is this just happening on you on stateless logic apps?

ccastrotrejo commented 3 weeks ago

Ok, I found the root cause of why this is happening. This is happening by design; stateless workflows don't support Split on in triggers. The Split on option is based on the triggerBody() and the number of elements it has. For example, if the triggerBody is an array of five paths, the stateful workflow will run 5 times. For this case, runs the workflow based on the "@triggerBody()?['Path']". This allows the workflow to not put the action inside a foreach loop (naturally, the workflow will handle the different paths) and run multiple times.

If you disable the Split on option in the trigger for stateful workflows, the behavior will be nesting the action in a foreach

image

As stated before, as the dynamic content that you want to set as input is "The path of the file or folder", this means that is individually by file or folder, meaning that once the action get the list of files/folders it needs to iterate through every file/folder to get the path of it. Thats the reason it adds automatically the foreach action.

You can read more about this here https://michalmolka.medium.com/azure-logic-app-split-on-and-for-each-1f25dc554145