kestra-io/kestra · error · PebbleException
The 'nanoId()' function field 'length' must be lower than: %
Error message
The 'nanoId()' function field 'length' must be lower than: %s
What it means
The nanoId() function enforces a maximum length of MAX_LENGTH (1000 characters). If the length argument exceeds 1000, this error fires to prevent excessive memory allocation and unreasonably long IDs.
Source
Thrown at core/src/main/java/io/kestra/core/runners/pebble/functions/NanoIDFunction.java:66
lineNumber,
self.getName()
);
}
return createNanoID(length, alphabet);
}
private static int parseLength(Map<String, Object> args, PebbleTemplate self, int lineNumber) {
var value = (Long) args.get(LENGTH);
if (value < 1) {
throw new PebbleException(
null,
"The 'nanoId()' function field 'length' must be greater than: 0",
lineNumber,
self.getName()
);
}
if (value > MAX_LENGTH) {
throw new PebbleException(
null,
"The 'nanoId()' function field 'length' must be lower than: " + MAX_LENGTH,
lineNumber,
self.getName()
);
}
return Math.toIntExact(value);
}
@Override
public List<String> getArgumentNames() {
return List.of(LENGTH, ALPHABET);
}
@Override
public Map<String, String> getArgumentDefaults() {
HashMap<String, String> defaults = new HashMap<>();
defaults.put(LENGTH, null);View on GitHub (pinned to 823fada927)
Solutions
- Reduce the length to 1000 or fewer. For ID generation, 8–32 characters is typical.
- If you need longer output, concatenate multiple nanoId calls or use a different generation strategy.
Example fix
# before
value: "{{ nanoId(length=5000) }}"
# after
value: "{{ nanoId(length=32) }}" Defensive patterns
Strategy: validation
Validate before calling
# Ensure length does not exceed 1000:
{% if myLength <= 1000 %}
{{ nanoId(length=myLength) }}
{% else %}
{{ nanoId(length=1000) }}
{% endif %} Prevention
- Use 8–32 character lengths for typical ID generation.
- Validate dynamic length variables against the upper bound.
- If longer output is needed, concatenate multiple nanoId calls.
When it happens
Trigger: Calling {{ nanoId(length=5000) }} or passing a dynamic variable for length that exceeds 1000.
Common situations: The author misconfigures a length from an input variable without validation. The author generates very long tokens for a use case that would be better served by a different approach.
Related errors
- The 'nanoId()' function field 'alphabet' must not be empty
- The 'nanoId()' function field 'alphabet' must not contain mo
- The 'nanoId()' function field 'length' must be greater than:
- In 'randomIn()' upper is less than lower
- Migration script [<scriptId>] has no checksum to repair.
AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14).
Data as JSON: /api/errors/19db4624ea5980e7.
Report an issue: GitHub.