Skip to content

Message interpolation does not work for expression language #61

Open
@paul-pop

Description

@paul-pop

Describe the bug
When using variable interpolation using expression language (EL) in messages, an exception is thrown where the property that is used in the evaluation of the expression is not found so the EL part of the message does not get interpolated.

Exception thrown in the ElTermResolver#interpolate(...) method:

javax.el.PropertyNotFoundException: ELResolver cannot handle a null base Object with identifier 'inclusive'

To Reproduce
An example where this happens is in @DecimalMin (or @DecimalMax) that has the default messages:

graphql.validation.DecimalMax.message={path} must be less than ${inclusive == true ? 'or equal to ' : ''}{value}
graphql.validation.DecimalMin.message={path} must be greater than ${inclusive == true ? 'or equal to ' : ''}{value}

For example, this GraphQL mutation with inputs:

mutation createModel(attributes: CreateModelAttributes!): Model
input CreateModelAttributes {
  value: BigDecimal @DecimalMin(value: "10", inclusive: true)
}

When passing in an invalid value like 1, will generate the following error message:

"/createModel/attributes/value must be greater than ${inclusive == true ? 'or equal to ' : ''}1"

The {path} and {value} are getting interpolated, but not the EL.

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