I finally got round to investigating a KNIME bug that has been driving me crazy for most of this year.
I reported this specific behaviour here on the forum back in February, but at that time I was only able to post my thoughts on it. Now I am in a position to post a simple example, so I hope this will assist with tracking down a fix
Let me explain further
I have a component (which I have unlinked in my workflow here to allow experimentation). The purpose of this component is to create a new path variable based on an existing path. But its purpose is irrelevant and serves to provide a demonstration of the problem.
In this very simple demo, the branch is chosen by setting the value of a variable “choose branch”.
If branch 1 (the lower branch) is chosen, everything is fine and the Case Switch End can turn green.
If branch 0 (the upper branch) is chosen, the Case Switch End cannot proceed because BOTH branches become active after the Edit Path Variable Filename component, even though the lower branch is INACTIVE.
Why does it become active? It is because the Component Output node of the Edit Path Variable Filename component has been configured using a flow variable to determine which flow variables to return to the workflow.
In the console, even though the branch is inactive, that Component Output node is still executing and is producing the following message:
WARN Component Output 5:2:0:627 Errors overwriting node settings with flow variables: Unknown variable "Required-Column-List"
Of course the “Required-Column-List” variable is unknown, because the component has not actually executed, and so this variable is not defined. The Component Output node SHOULD NOT be executing!
If I reconfigure the Component Output node so that it does not have the flow variable configuration performed, then everything behaves as it should and the lower branch remains inactive when it is not selected. Of course my component doesn’t then return the flow variable so becomes useless. I could have it simply return all of its flow variables but I really don’t want to have my components flooding the workflow with variables!
As a big user of components to save me time, this bug is a huge time waster to me. At least I think I now know which of my components will work and which cannot be used inside conditional branches, but it would be great if this could be looked into and fixed. The only responder to my previous post was @ArjenEX who mentioned that:
This demo of course is now using the CASE Switch node, and I have tried it in both KNIME 4.7.7 and KNIME 5.1.1 and the problem persists. I’ve now looked up AP-19721 in the 4.7 release notes and see that although it appears related, the scenario is a little different:
AP-19271: Component within a component still get executed, although the outer
component is in an inactive CASE Switch branch
It would be great if this bug could be looked into. Currently I see no workaround other than to not use such components in conditional branches. thanks.
Here is a workflow which demonstrates the issue
Component Stays Active on Inactive Branch - BUG demo.knwf (705.6 KB)