Skip to content
This repository was archived by the owner on Nov 14, 2024. It is now read-only.

not automatically converting Logic App action input/output to json #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MichielVanwelsenaere
Copy link
Contributor

This PR changes the way Logic App input/output content is treated.
Instead of automatically converting it to json -which gives exceptions when the content is not in the json format- it is treated as a string

Closes #62

@MichielVanwelsenaere
Copy link
Contributor Author

I see the tests are failing, before updating them could you give me some feedback on this one? Are there better options to treat the action input/output content or is this indeed the way to go?

@stijnmoreels
Copy link
Contributor

stijnmoreels commented Oct 7, 2020

I see the tests are failing, before updating them could you give me some feedback on this one? Are there better options to treat the action input/output content or is this indeed the way to go?

We'll have to check with @mbraekman since he has the most expirence with using the testing framework in the wild.

@mbraekman
Copy link
Contributor

First thought: isn't the in-/output of a Logic App action always json-format? One of the fields within the in-/output could be containing a different format (base64/xml/...), but other than that it's supposed to be json, no?

If not, I might have missed some type of scenario, so could you give an example of where this differs?

@MichielVanwelsenaere
Copy link
Contributor Author

In this specific scenario we are using the compose action to show xml content (the reason for this is another matter). The action is defined as below:

"Track_BaseLoadEnvelope": {
    "inputs": "@xml(base64ToBinary(body('Transform_CDMMessageBundle_To_BaseLoadEnvelope')?['Content']))",
    "runAfter": {
        "Transform_CDMMessageBundle_To_BaseLoadEnvelope": [
            "Succeeded"
        ]
    },
    "trackedProperties": {
        "Content-Type": "application/xml"
    },
    "type": "Compose"
},

When you check on a similar action the input/output in the Logic App designer it will show a json. YET, when checking the on the Azure Management API the 'Workflow Run Actions - List' API endpoint (the one leveraged by this framework) the output url returns xml format. This (designer vs API) is probably how the perception got created that the input/output is always json.

I did do a doublecheck and calling the output url form postman shows that a content-type header is returned set to 'application/xml'. I do think that this is because of the @xml() we are specifying in the input of the action ourselves and not that this is a native Logic Apps runtime behavior.

My suggestion; leverage 'string' from now as return value as an obvious bugfix and create (if desired) a separate feature request for more intelligent content handling.

Let me know your thoughts so I can start having a look at adopting the tests if that's considered the way to go.

Copy link
Contributor

@tomkerkhove tomkerkhove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do this, then you have to provide an integration test to ensure it works by the least if you ask me.

I'm reluctant to move to something else than JSON but if it is what it is, why not 🤷‍♂️ But it should be backed by tests at least.

@mbraekman
Copy link
Contributor

+1 on the integration test-remark from Tom.

Also +1 on the intelligent content-handling. Can be as simple as:
-> if header "Content-Type: application/json" parse as JToken
-> if header "Content-Type: application/xml" parse as XDocument
--> if parsing fails: return as string - otherwise invalid in-/output set by developer would cause the Fx to fail.
-> else return string

Although the use of this Fx is currently rather limited, we need to ensure we don't break the logic anyone might have implemented, so could this check (for json at least) already be included?
If agreed upon by @tomkerkhove, of course.

@tomkerkhove
Copy link
Contributor

What's the status on this @MichielVanwelsenaere ?

@MichielVanwelsenaere
Copy link
Contributor Author

What's the status on this @MichielVanwelsenaere ?

haven't found the time yet... 😐

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

Successfully merging this pull request may close these issues.

Unable to retrieve xml content / Invalid naming
4 participants