Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple 'RunAfter' statements for a single action fails to produce valid mermaid code #23

Closed
SjoerdV opened this issue Aug 16, 2023 · 6 comments
Assignees

Comments

@SjoerdV
Copy link

SjoerdV commented Aug 16, 2023

Describe the bug
One action called Send_email in a LA has the following code

"runAfter": {
	"CalculateDigest": [
    	"Succeeded"
	],
	"Compose_2": [
    	"Succeeded"
	],
	"HTTP": [
    	"Succeeded"
	]
}

This will lead to a mermaid construct as follows

CalculateDigest Compose_2 HTTP --> Send_email

This will fail to render

Add error message

Parse error on line 7:
...CalculateDigest Compose_2 HTTP --> S
---------------^
Expecting 'SEMI', 'NEWLINE', 'EOF', 'AMP', 'START_LINK', 'LINK', got 'ALPHA'

Expected behavior
Multiple runAfter statements should be parsed to mermaid as follows:

CalculateDigest --> Send_email
Compose_2 --> Send_email
HTTP --> Send_email

Screenshots
NA

PowerShell version:
Run $PSVersionTable command in PowerShell host
e.g.

Name                           Value
----                           -----
PSVersion                      7.3.6
PSEdition                      Core
GitCommitId                    7.3.6
OS                             Linux
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

LogicAppDocs version

  • Version 1.1.1

Additional context
NA

@stefanstranger
Copy link
Owner

Hi @SjoerdV,

Thanks for sharing this issue with me. Would it be possible to share the complete Log Analytics of PowerAutomate Flow code with me, so I can test this?

If so please remove any sensitive content. This can also be shared using a secret gist if you prefer.

https://docs.github.com/en/get-started/writing-on-github/editing-and-sharing-content-with-gists/creating-gists

@stefanstranger stefanstranger self-assigned this Aug 17, 2023
@SjoerdV
Copy link
Author

SjoerdV commented Aug 17, 2023

I'll do you one better. The actual piece of code that needs adjustment is here:

# Create links between runafter and actionname properties
foreach ($object in $objects) {
if ($object | Get-Member -MemberType NoteProperty -Name 'RunAfter') {
# Check if the runafter property is not empty
if (![string]::IsNullOrEmpty($object.RunAfter)) {
$mermaidCode += " $($object.RunAfter) --> $($object.ActionName)" + [Environment]::NewLine
}
}
}

Needs a foreach to account for multiple runAfter keys.

example:

# Example Data
$runAfterObj = @'                    
{
    "runAfter": {
        "CalculateDigest": ["Succeeded"],
        "Compose_2": ["Succeeded"],
        "HTTP": ["Succeeded"]
    }
}
'@ | ConvertFrom-Json -AsHashtable

# Modified code
foreach ($Key in $runAfterObj.runAfter.Keys) {
  $mermaidCode += "    $($Key) --> $($object.ActionName)" + [Environment]::NewLine
}

@stefanstranger
Copy link
Owner

Hi @SjoerdV ,

Thanks for the help and code🙏Let me find some time to update the code in the main branch.

@stefanstranger
Copy link
Owner

stefanstranger commented Aug 18, 2023

@SjoerdV I created an new branch with the fix. Can you please download this branch https://github.com/stefanstranger/logicappdocs/tree/issue23 and test if this fixed your issue?

git clone --single-branch --branch issue23 https://github.com/stefanstranger/logicappdocs.git

Regards,
Stefan

@SjoerdV
Copy link
Author

SjoerdV commented Aug 18, 2023

@stefanstranger works like a charm! I tested both single and multiple runafter constructs.
Great work building this.

stefanstranger added a commit that referenced this issue Aug 19, 2023
Fix for actions with multiple runafter properties. isuse #23
@stefanstranger
Copy link
Owner

Merged changes into main branch. Closing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants