octobercms/october · error · Twig\Error\SyntaxError
The "%s" modifier takes exactly one argument (0 given).
Error message
The "%s" modifier takes exactly one argument (0 given).
What it means
The ttl modifier of the {% cache %} tag requires exactly one argument. If the parser sees the closing parenthesis immediately after the opening one, it throws this SyntaxError - the TTL value was omitted entirely ({% cache 'key' ttl() %}).
Source
Thrown at modules/cms/twig/tokenparser/CacheTokenParser.php:36
* @return PartialNode
*/
public function parse(Token $token): Node
{
$stream = $this->parser->getStream();
$key = $this->parser->parseExpression();
$ttl = null;
while ($stream->test(Token::NAME_TYPE)) {
$k = $stream->getCurrent()->getValue();
if (!in_array($k, ['ttl'], true)) {
throw new SyntaxError(sprintf('Unknown "%s" configuration.', $k), $stream->getCurrent()->getLine(), $stream->getSourceContext());
}
$stream->next();
$stream->expect(Token::OPERATOR_TYPE, '(');
$line = $stream->getCurrent()->getLine();
if ($stream->test(Token::PUNCTUATION_TYPE, ')')) {
throw new SyntaxError(sprintf('The "%s" modifier takes exactly one argument (0 given).', $k), $line, $stream->getSourceContext());
}
$arg = $this->parser->parseExpression();
if ($stream->test(Token::PUNCTUATION_TYPE, ',')) {
throw new SyntaxError(sprintf('The "%s" modifier takes exactly one argument (2 given).', $k), $line, $stream->getSourceContext());
}
$stream->expect(Token::PUNCTUATION_TYPE, ')');
if ($k === 'ttl') {
$ttl = $arg;
}
}
$stream->expect(Token::BLOCK_END_TYPE);
$body = $this->parser->subparse([$this, 'decideCacheEnd'], true);
$stream->expect(Token::BLOCK_END_TYPE);
$body = new CacheNode($key, $ttl, $body, $token->getLine());View on GitHub (pinned to b608633a7e)
Solutions
- Supply a single TTL value in minutes: {% cache 'sidebar' ttl(3600) %}.
- If you want the default TTL, drop the modifier entirely: {% cache 'sidebar' %}.
- Re-save the template and reload - the error is compile-time, so the page will not render until fixed.
Example fix
{# before #}
{% cache 'sidebar' ttl() %}
{# after #}
{% cache 'sidebar' ttl(3600) %} Defensive patterns
Strategy: validation
Validate before calling
$env = app('twig.environment');
try {
$env->parse($env->tokenize(new \Twig\Source($templateBody, $fileName)));
} catch (\Twig\Error\SyntaxError $e) {
// reject empty ttl() before the template reaches production
} Try / catch
try {
$env->parse($env->tokenize(new \Twig\Source($body, $name)));
} catch (\Twig\Error\SyntaxError $e) {
// flag 'takes exactly one argument (0 given)' for immediate fix
} Prevention
- Never leave placeholder ttl() in scaffolds - omit the modifier for the default TTL.
- Review diff hunks containing cache tags before merging.
- Run a template lint step on save in your editor or CI.
When it happens
Trigger: Writing {% cache 'sidebar' ttl() %} with empty parentheses during template compilation; typically a placeholder that was never filled in or a copy-paste that lost the value.
Common situations: Template scaffolding left with an empty ttl(); refactoring that removed the value but kept the parens; misunderstanding ttl as a flag.
Related errors
- Unknown "%s" configuration.
- The "%s" modifier takes exactly one argument (2 given).
- Invalid syntax in the component tag. Line %s
- Invalid syntax in the content tag. Line %s
- Invalid syntax in the framework tag. Line %s
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/ec52e2da28a7cddd.
Report an issue: GitHub.