Subworkflow returns “Query is missing” — JSON field not passing to Tavily Tool

Hey everyone,

I’m using a template for a newsletter automation workflow that includes a Tavily subworkflow for live search. The structure includes a main flow and a subworkflow (called “Tavily Tool”) triggered using “When Executed by Another Workflow”.

The Tavily node in that subworkflow uses this JSON expression:

{
“api_key”: “my_key”,
“query”: “{{ $json.query.replace(/”/g, ‘\"’) }}",
“search_depth”: “basic”,
“include_answer”: true,
“topic”: “news”,
“include_raw_content”: true,
“max_results”: 3
}

Everything matches the original template exactly, but when I test the Tavily node, I get this error:

Bad request - please check your parameters
Query is missing

In the subworkflow, the input node (“When Executed by Another Workflow”) says:

No fields - item(s) exist, but they’re empty.

So clearly, $json.query is undefined. But the main workflow should be passing it in — the original template seems to work without hardcoding anything.

What I’ve tried:

  • “Accept all data” and “Define fields” — no difference.
  • Added mock data to test the subworkflow — that works, so the issue is upstream.
  • Confirmed API key and JSON are valid.

How do I make sure the query field from the main workflow is actually passed into the subworkflow properly?

Would really appreciate help — thanks!

The best strategy is to examine the input to the execute workflow node and the output of the when executed by another workflow node to isolate where the value is going missing (or if it is).

BTW, the Bad Request error message may point to the service complaining about a blank (vs. undefined) value, so possibly it’s just a naming thing (e.g. “Query” vs. “query”).

Here’s a workflow/subworkflow (in one). Paste it into a new workflow in your environment and modify the Execute Workflow node to call “itself” as a subworkflow. This might help you compare what is/isn’t working (or should/shouldn’t work).