What does index -1 mean when it shows up in the output data preview for a Data Stream Action in Flow Designer?
If you're here, it's probably because you're seeing an unexpected result in the "Output Data" for your Data Stream action in Flow Designer. Instead of showing any output items, all you get is a big text dump starting with "index":-1.
Here's a trimmed example of the preview output from one of my affect actions, for illustrative purposes:
{"index":-1,"co_collection":"{\"serializationFormat\":\"JSON\",\"version\":\"1.0\",\"complexObject\":{\"name$\":\"dsareport\",\"$COCollectionField\":[{\"self\":{\"$cv\":{\"$c\":\"java.lang.String\",\"$v\"
Why It's Happening
This issue happens if the JSON representation of the output items would be too long for the preview window. By default, the preview caps out at 16384 bytes (approximately 22,000 characters). This limit applies to the sum total combined JSON output of all previewed output objects, it is not per-object!
If the displayed JSON would be longer than 22k characters, the preview fails. The failed preview will cause you to see garbage output in the preview, like that described above.
How to Work Around The Issue
The good news is that only the preview is affected. Even if the preview is showing garbage, you can still expect the actual output (that would appear in a staging table, for example) to be correct. This means you can get away with having the broken preview as long as you're confident that the actual output is correct.
If that's not good enough and you need the preview to work, you must raise the reporting size limit for flow variables. In order to raise the limit, you must modify the system property called "com.snc.process_flow.reporting.serialized.val_size_limit"
Alternatively, you could just try adjusting your action inputs to limiting the output in such a way that the preview data will fit within the default size limit!
https://www.servicenow.com/community/developer-articles/what-does-index-1-mean-when-it-shows-up-in-the-output-data/ta-p/2330014