question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conditional flow fails with collections in API Provider

See original GitHub issue

This is a…


[ ] Feature request
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Documentation issue or request

Description

Conditional flows cannot be used with collections in Syndesis, but API Provider makes a collection around its request body, even when it is specified in the API specification to contain only one object of specified type. Example: conditional-provider.zip In this integration you can see that in the specification in the POST method it expects request body of Task. I’d expect that to be one Task. So if I create a condition ${body.completed} it should work, or at least ${body["completed"]}. I tried also splitting it, but split doesn’t work well on these types of collections (see #4862). Also I tried ${body[0]["completed"]} but that also didn’t work for some reason. The log reported something along the lines of cannot call method [0]["completed"] on ArrayList.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
zregvartcommented, Jul 25, 2019

With most HTTP-related functionality (custom API connectors, API provider, webhook) we use something that we call “unified” data shape, this is the shape that we try to standardize on so we can easily both use it in the mapping step and have a common data format when using different HTTP-related functionality in the same flow/integration. The origins of this shape are from the inability to specify multiple data shapes for one step, in this case we need two one for HTTP headers (parameters) and one for the HTTP body, so therefore we create a new data shape that contains both.

This shape has a specific JSON schema defining it which is auto-generated (custom API connectors, API provider) or provided by the user (webhook).

The fact that there’s a body property in the body of the Camel message is because of this. This also reflects in the use of mapper, filter steps or here in the conditional flows.

We have made provisions in split/aggregate for this specific data shape in order for the experience to be better for the end user. I think there are some improvements for conditional flows planned for next release.

In the long term I would look to support defining the data shape(s) differently, this is a limitation we have with the mapper and the way it can only express the shape of the Camel message body and needs to be addressed there first.

1reaction
mmuzikarcommented, Jul 24, 2019

@christophd Yes you are right, that works. It is certainly not the most obvious solution though. If this is the intended solution, it should be at least documented somewhere (@TovaCohen can you elaborate if it is already documented, or add a mention of that in the documentation?). But this is a thing you don’t really expect that you have to read documentation for, maybe a little mention in the UI where there is the “Provide a condition that you want to evaluate (for example, ${in.header.type} == 'note' or ${in.body.title} contains 'Important').” Or in a perfect world if the datatype is a JSON schema there could be a note added or something. (cc @syndesisio/uxd )

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conditions with flow variables | Apigee X - Google Cloud
Conditions are used to define API proxy conditional flows to backend API resources, described in Create conditional flows to backend API resources. For...
Read more >
3 Power Automate Error-Handling Patterns You Must Know
Learn to use these 3 Power Automate error-handling patterns: 1. Try, Catch Finally, 2. Terminate Actions, 3. Get the Flow Run URL.
Read more >
Conditional Workflows in Postman
The workflow: First makes the API call to GET the list of approved food for Cooper from the database. All 3 meals in...
Read more >
Flow Conditional Visibility Considerations - Salesforce Help
Before you set visibility for a screen component, understand the behavior of conditional visibility in flows.Required Editions Available in: both Salesfor.
Read more >
Configuring flows | Apigee Edge
Flows enable you to program the behavior of an API by letting you ... In the Navigator menu, an example conditional flow named...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found