Issue formatting Array Aggregator output into dynamic JSON array (directUrls) for Apify Actor

:bullseye: What is your goal?

Collect post URLs from Module 4 and pass them into Module 5’s Input JSON field under the directUrls array parameter as a single batch:

Ex:

{
“directUrls”: [
“https://www.instagram.com/p/…”,
“https://www.instagram.com/p/…”
],
“resultsLimit”: 15
}

:thinking: What is the problem & what have you tried?

Auto-Escaping / String Injection Issue:

When using join(map(4.Array; url); “","”) inside the quotes, Make automatically escapes the quotes ("), turning the output into a single concatenated string rather than separate array elements.

Result: Apify throws a regex validation error (Field input.directUrls.0 must match pattern…).

When mapping map(4.Array; url) directly into directUrls: […], the array evaluates as empty.

Result: Apify throws Field input.directUrls must NOT have fewer than 1 items, even though the url field is checked under Module 4’s Aggregated fields.

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

Hey there,

can you show a screenshot of the error you are getting and show the actual input bundle that the module received?

Hello,

Please share input data structure. Right now it is hard to suggest solution.

Potentially you have at least two possible solutions.

First one - use, for example * in join() function and use additional replace to change * to " so Make won’t escape them or use text aggregator.

There are two separate failures mixed together here, and they are worth splitting before any fix makes sense.

The empty array is the one to solve first. If map(4.array; url) resolves to nothing, the problem sits on the aggregator side and not in the JSON. Run the scenario once and open module 4 in the execution history, Output tab. Two things to read there. First, the actual key name inside each item of the array. The Array Aggregator names the items after the structure of the source module, so a URL that lives inside a nested collection comes out as something like item.data.url, and a plain url in map() then finds nothing. Second, the Source Module setting of the aggregator. It has to point at the module that starts the cycle you want to close, usually the iterator or the search module, not simply the module directly in front of it. A wrong source module produces one bundle with the wrong items or with none.

The escaping is the second problem, and the part I would drop there is the hand built string. When you put quotes around a mapping inside an Input JSON field, Make treats the result as text and escapes what you typed, which is exactly the single concatenated string Apify is complaining about. Let a module produce the JSON instead.

Insert a JSON module, Create JSON, before module 5. Define a data structure with directUrls as an array of text and resultsLimit as a number. Map the aggregator array into directUrls and 15 into resultsLimit. Then map the single JSON output of that module into the Input JSON field of module 5 and put nothing else in that field. The quoting is then done by the JSON module and cannot come out escaped.

If you have to stay with a hand written field for some reason, the placeholder route mszymkowiak mentioned does work. Join with a character that will not appear in your data, then replace that character with the quote and comma sequence in a second step. It breaks the moment a URL contains the placeholder, which is why I would keep the Create JSON route.

One useful signal either way: the pattern error on input.directUrls.0 means the first element arrived as one long concatenated string, so that run took the escaping path. The must NOT have fewer than 1 items error means the array itself was empty. If you see both, you are looking at two different runs with two different causes, and fixing the aggregator first will make the second one easier to read.