Skip to content

default filter requires an explicit argument and fails without one #1339

Open

Description

@Nuhiat-Arefin

The default filter declares default_value as a required parameter, so a template that uses the filter without an argument fails to render. Jinja2 makes the argument optional and supplies an empty string.

Affected: master df50b0d7. Releases 2.7.6, 2.8.3 and 2.8.4 carry the same declaration.

Reproduction

{{ 'a'|default }}

Jinja2 renders a. Jinjava raises:

com.hubspot.jinjava.interpret.FatalTemplateErrorsException: Argument named 'default_value' is required but missing for filter default

Root cause

DefaultFilter registers default_value with required = true. AbstractFilter.validateArgs rejects the call before the filter body runs, so no path returns the input unchanged when the argument is omitted.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions