Sub Workflow not returning output data to main workflow

Describe the problem/error/question

I create a RestAPI workflow, which was monolithic, but it was working.

To increase maintainability, I decided to split the workflow into a global RestAPI entrypoint and several sub-workflows, which are processing the requests. The global entrypoint contains a webhook request nodes per HTTP method and each of the uses a paramter for the endpoint, which is split in the next steps and then route the requests to the appropriate sub-workflows.

That’s working quite well so far, even if I haven’t split all the workflows right now. I am now facing the issue, that the outsourced workflow is working properly and returning the output data, except for one case.

If I check the executions of the sub-workflow, I can see, that the workflow was called and ended properly and the data have been generated for all three different routes in the sub workflow, as they should (see output below the workflow diagrams), but the “invalid corekey” route’s output data are not returned for some reason.

What is the error message (if any)?

No, message, I do not get data from the sub-workflow to the main workflow. The sub-workflow is running well, but it seems that data are not returned properly for all cases.

Please share your workflow

Main Workflow

Sub Workflow

Share the output returned by the last node

Output of the “JWT creation” route (returns data successfully):

[
  {
    "response_code": 200,
    "response_data": {
      "result": true,
      "message": "Authentication of corekey successful.",
      "data": {
        "token": "eyJh...z77c2Rc" 
      }
    }
  }
]

Output of the working “invalid credentials” route (returns data successfully):

[
  {
    "response_code": 403,
    "response_data": {
      "result": false,
      "message": "Invalid credentials",
      "data": {}
    }
  }
]

Output of the working “invalid corekey” route (returns NO data, even they are valid):

[
  {
    "response_code": 403,
    "response_data": {
      "result": false,
      "message": "Invalid corekey.",
      "data": {}
    }
  }
]

Information on your n8n setup

  • n8n version:1.104.1
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): No idea. Where can I find that information?
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system: Linux

Can you send a screenshot of the output of this node after it ran. I suspect you’re not properly mapping out the response of the sub workflow

Hi @Wouter_Nigrini,

thanks for helping.

The outputs shown in the initial post are copied exactly from the output of this node, but nevertheless, here is a screenshot of the node:

As you see on the right, the ouput is generated as it should. And again, it is working with the same output data format in the other cases.

Oh and I totally forgot to mention, that this exact route is working properly in the monolithic version. I simply copied the nodes and pasted it into a new workflow, which is now called from the main workflow.

Then that is the output you should see in the parent workflow calling this one. I cant see any issue with your workflows. Is the parent just never continuing or does it continuing before the sub workflow executed or is it just returning blank data?

Also on the execute another workflow node, make sure this setting is enabled (should be the default) when you click the add option button at the bottom just to make sure

That’s the issue. The output is generated, but the “execute sub workflow” trigger node in the main workflow does not get the data in for route. But as said, only for this “invalid corekey” route. The others are working properly.

The calling node in the main workflow stops here. This is the execution log:

Is set and works for the other routes in the sub workflow.

Try setting this on your parent Execute workflow node and see if it works.

Activated that option and called the enpoint again. More or less the same result as before:

  • the sub workflow generated the expected output, but
  • the output was not sent back to the main workflow
  • with the option activated, an empty output is sent to the next node and that results in an error that the empty output cannot be converted.

Ok great! This tells me that the execute workflow is in fact waiting for the sub workflow to finish and return a result, but it is empty.

You’ll need to go to your executions tab, then double click the first node to see what data was passed into the sub workflow. Copy it, then run the sub workflow with that data pinned to the execute node so you can debug. There is a bug with the data that gets sent into the sub workflow at run time which is causing your workflow to fail somewhere

Also go into both workflows settings by clicking the 3 dots at the top right and enable this setting so we can make sure it records the execution data

Hi @Wouter_Nigrini,

I may give it a shot, but again, the sub-workflow is running successfully on ALL three routes, so there is definitely no issue with the data handed over to the sub-workflow. As shown in the screenshots, all three routes generate a valid output JSON, all three looking the same (except the data itself, of course).
Simply, the data of the last route (invalid corekey) isn’t returned to the main workflow.

I am almost sure, there is no error in the subworkflow. I checked that several times. But as said, I’ll follow your instructions and post the results here.

Here is the result.

I copied the data provided to the sub-workflow, from the executions tab and pasted it into the entry node of the sub-workflow and ran the workflow. As you see, no error occurs.

This is a screenshot of the code node at the end of the workflow. Data was generated as expected.

Screenshot of the “execute sub-workflow” node in the main workflow, showing, that data isn’t returned.

To me it seems, that this is a bug somewhere in n8n and I tend to create an issue ticket in GitHub, except you have some other ideas to verify the workflows.

@Wouter_Nigrini I managed to fixed the issue. :raising_hands:

I remembered this post I read yesterday. The problem described in this post, is quite similar to mine. One route of the workflow wasn’t returning data. No idea why I didn’t get the deeper meaning of it earlier, but yeah, maybe it was already too late yesterday :laughing:

The issue was, that the workflow didn’t return the data, as the MERGE node on another route didn’t get data for all inputs. So this node was still waiting for incoming data and didn’t finish, even the workflow itself finished successfully. Seems like this leads to some strange behaviour with finishing a sub-workflow and returning data.

So, the problem in my workflow was, that there is an if node, that checks if the so-called corekey exists, before further checks are carried out. For the “invalid corekey” route, the merge node is not getting it’s second input, as the if node activated the other route and so the merge node was waiting for the second input. (see screenshot).

The purpose of the merge node is, to merge the data from the input data and the result from the SQL query (maybe there is a better solution than this). The solution to my issue was, to change the positions of the merge and the if node in the flow. So, merge both data paths first and then decide, what route to activate.

So, even if the workflow was working successfully, it was logically not fully correct.

Thanks for your time and help.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.