twigphp/Twig · error · Twig\Error\RuntimeError
The list type " " does not exist, known types are: " ".
Error message
The list type "%s" does not exist, known types are: "%s".
What it means
createListFormatter validates the $type argument (the list connection type, e.g. 'and'/'or') against IntlExtension::availableListTypes(). An unknown type throws this RuntimeError listing the supported list types.
Solutions
- Use only types listed in the error (keys of availableListTypes(), typically 'and' and 'or')
- Fix the type string in the template or PHP call
- Validate config/input list types against availableListTypes() before rendering
- Default to 'and' when the configured type is unknown
Example fix
// before
{{ items|format_list(type='but') }}
// after
{{ items|format_list(type='and') }} Defensive patterns
Strategy: validation
Validate before calling
if (!isset(IntlExtension::availableListTypes()[$type])) { throw new \InvalidArgumentException("Unknown list type $type"); } Type guard
function isKnownListType(string $t): bool { return isset(IntlExtension::availableListTypes()[$t]); } Try / catch
try { $out = $intl->formatList($strings, $type); } catch (\Twig\Error\RuntimeError $e) { if (str_contains($e->getMessage(), 'list type')) { $out = $intl->formatList($strings, 'and'); } else { throw $e; } } Prevention
- Restrict list type choices to 'and'/'or' in UI and config
- Validate before rendering templates
- Keep default type 'and'
When it happens
Trigger: Calling the format_list filter (formatList -> createListFormatter) with a type argument not in availableListTypes() — e.g. 'nor', 'but', or a typo like 'adn' instead of 'and'.
Common situations: Assuming arbitrary conjunctions are supported; typos in template arguments; user-supplied list type values passed straight through from config or request input.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- The list width " " does not exist, known widths are: " ".
- The date format " " does not exist, known formats are: " ".
- The time format " " does not exist, known formats are: " ".
- The style " " does not exist, known styles are: " ".
- The number formatter attribute
AI-assisted analysis of twigphp/Twig@a414c3a491 (2026-09-13).
Data as JSON: /api/errors/f01dc30a83fa22b9.
Report an issue: GitHub.
Appendix: source
Thrown at extra/intl-extra/IntlExtension.php:614
}
foreach ($textAttrs as $name => $value) {
$this->numberFormatters[$hash]->setTextAttribute(self::NUMBER_TEXT_ATTRIBUTES[$name], $value);
}
foreach ($symbols as $name => $value) {
$this->numberFormatters[$hash]->setSymbol(self::NUMBER_SYMBOLS[$name], $value);
}
return $this->numberFormatters[$hash];
}
private function createListFormatter(?string $locale, string $type, string $width): \IntlListFormatter
{
$listTypes = self::availableListTypes();
if (!isset($listTypes[$type])) {
throw new RuntimeError(\sprintf('The list type "%s" does not exist, known types are: "%s".', $type, implode('", "', array_keys($listTypes))));
}
$listWidths = self::availableListWidths();
if (!isset($listWidths[$width])) {
throw new RuntimeError(\sprintf('The list width "%s" does not exist, known widths are: "%s".', $width, implode('", "', array_keys($listWidths))));
}
if (null === $locale) {
$locale = \Locale::getDefault();
}
$listTypeValue = $listTypes[$type];
$listWidthValue = $listWidths[$width];
$hash = $locale.'|'.$listTypeValue.'|'.$listWidthValue;
if (!isset($this->listFormatters[$hash])) {View on GitHub (pinned to a414c3a491)