{"record":{"id":"03090db20df8761d","repo":"kestra-io/kestra","slug":"the-nanoid-function-field-alphabet-must-not-03090d","errorCode":null,"errorMessage":"The 'nanoId()' function field 'alphabet' must not contain more than: %s characters","messagePattern":"The 'nanoId\\(\\)' function field 'alphabet' must not contain more than: (.+?) characters","errorType":"exception","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/NanoIDFunction.java","lineNumber":45,"sourceCode":"        Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) {\n        int length = DEFAULT_LENGTH;\n        if (args.containsKey(LENGTH) && (args.get(LENGTH) instanceof Long)) {\n            length = parseLength(args, self, lineNumber);\n        }\n        char[] alphabet = DEFAULT_ALPHABET;\n        if (args.containsKey(ALPHABET) && (args.get(ALPHABET) instanceof String)) {\n            alphabet = ((String) args.get(ALPHABET)).toCharArray();\n        }\n        if (alphabet.length == 0) {\n            throw new PebbleException(\n                null,\n                \"The 'nanoId()' function field 'alphabet' must not be empty\",\n                lineNumber,\n                self.getName()\n            );\n        }\n        if (alphabet.length > MAX_ALPHABET_LENGTH) {\n            throw new PebbleException(\n                null,\n                \"The 'nanoId()' function field 'alphabet' must not contain more than: \" + MAX_ALPHABET_LENGTH + \" characters\",\n                lineNumber,\n                self.getName()\n            );\n        }\n        return createNanoID(length, alphabet);\n    }\n\n    private static int parseLength(Map<String, Object> args, PebbleTemplate self, int lineNumber) {\n        var value = (Long) args.get(LENGTH);\n        if (value < 1) {\n            throw new PebbleException(\n                null,\n                \"The 'nanoId()' function field 'length' must be greater than: 0\",\n                lineNumber,\n                self.getName()\n            );","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/NanoIDFunction.java#L27-L63","documentation":"The nanoId() function enforces a maximum alphabet length of MAX_ALPHABET_LENGTH (256 characters). If the provided alphabet string exceeds 256 characters, this error fires. The cap exists to keep the byte-rejection loop bounded and memory predictable.","triggerScenarios":"Passing an alphabet string longer than 256 characters: {{ nanoId(alphabet='....256+ chars....') }}. A dynamically generated alphabet (e.g. from a large character set variable) that exceeds the cap.","commonSituations":"The author builds an alphabet from a full Unicode block or concatenates multiple character sets, accidentally exceeding 256 characters.","solutions":["Reduce the alphabet to 256 characters or fewer. For most use cases, 16–64 characters is sufficient.","If you need a broader character set, consider generating IDs differently or using the default 64-character URL-safe alphabet."],"exampleFix":"# before\nvalue: \"{{ nanoId(alphabet=veryLongAlphabetVar) }}\"\n# after\nvalue: \"{{ nanoId(alphabet='0123456789abcdef') }}\"","handlingStrategy":"validation","validationCode":"# Ensure alphabet length is within the 256-char limit:\n{% if myAlphabet|length <= 256 %}\n  {{ nanoId(alphabet=myAlphabet) }}\n{% else %}\n  {{ nanoId() }}\n{% endif %}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep alphabets to 16–64 characters for typical ID generation.","Do not generate alphabets from full Unicode blocks.","Use the default alphabet unless you have a specific character-set requirement."],"tags":["pebble-function","nanoid","validation"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}