AutomateAlong

Error messages › Expressions

substring() asked for more text than there is

Seen when a run fails · Updated 8 November 2026

The message

The template language function 'substring' parameters are out of range: 'start index' and 'length' must be non-negative integers and their sum must be no larger than the length of the string.

What it means

substring(text, start, length) fails when start + length goes past the end of the text. Shorter text than expected, a blank, or indexOf returning -1 all cause it.

How to fix it

  1. Cap the length: substring(<text>, 0, min(50, length(<text>))).
  2. If start comes from indexOf, check it isn't -1 first: if(greater(indexOf(<text>, '-'), -1), …, <text>).
  3. Or use slice(<text>, 0, 50), which doesn't fail on short text.

Not quite your message? Paste the whole thing into the Flow Doctor. It reads the step, property and expression out of your exact wording and, for the stubborn ones, the AI reads the flow it happened in.

How to find the full error in Power Automate

  1. Open the flow and look at 28-day run history.
  2. Select the failed run (red cross), then the step with the red cross.
  3. The error is in that step's box; some are under Show raw outputs. Copy the whole thing, including the code at the start.

Other Expressions errors

AutomateAlong is independent and isn't affiliated with Microsoft. Microsoft and Power Automate are trademarks of the Microsoft group of companies.