You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
String % operand raises a coercion error instead of printf-style formatting #1340
Jinja2 applies printf-style formatting to 'text' % operand. Jinjava parses % as the JUEL modulo operator and coerces the left operand to a number, so a string left operand fails to render.
Affected: master df50b0d7. Releases 2.7.6, 2.8.3 and 2.8.4 behave the same.
Reproduction
{{ 'number'%r }}
Jinja2 renders number. Jinjava raises:
com.hubspot.jinjava.interpret.FatalTemplateErrorsException: Cannot coerce 'number' of class java.lang.String to class java.lang.Double (incompatible value)
Root cause
ExtendedParser maps the % token to AstBinary.MOD (src/main/java/com/hubspot/jinjava/el/ext/ExtendedParser.java:421-424). The JUEL implementation of MOD converts both operands to numbers, and there is no string formatting path for a string left operand.
Activity