You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (Jira)" <ji...@apache.org> on 2026/10/05 13:42:00 UTC
[jira] [Work started] (WW-5757) BeanValidationInterceptor resolves the interpolated constraint message as a text key instead of the message template
[ https://issues.apache.org/jira/browse/WW-5757?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Work on WW-5757 started by Lukasz Lenart.
-----------------------------------------
> BeanValidationInterceptor resolves the interpolated constraint message as a text key instead of the message template
> --------------------------------------------------------------------------------------------------------------------
>
> Key: WW-5757
> URL: https://issues.apache.org/jira/browse/WW-5757
> Project: Struts 2
> Issue Type: Bug
> Components: Plugin - Bean Validation
> Reporter: Lukasz Lenart
> Assignee: Lukasz Lenart
> Priority: Major
> Fix For: 6.13.0, 7.5.0
>
>
> {{BeanValidationInterceptor}} builds the field and action error text from {{ConstraintViolation.getMessage()}}, which is the message *after* the Bean Validation provider has interpolated it, and passes that string to the Struts text provider ({{getText(...)}}) as the text key.
> The key a developer declares is the constraint's {{message}} attribute, which is what {{ConstraintViolation.getMessageTemplate()}} returns. Using the interpolated message as the key means:
> * a developer-declared Struts key only resolves when the provider leaves the message untouched;
> * provider-interpolated text that matches no key is not shown as the provider produced it, but is handed to the text provider as default text and processed again, as if it were a Struts message.
> The plugin documentation only promises that the {{message}} value is looked up as a Struts key; it does not say that provider-produced text goes through the text provider.
> h2. Change
> Resolve the error text from the template, and keep the provider's message otherwise:
> * look up {{getMessageTemplate()}} in the Struts bundles, and call {{getText}} with it only when {{hasKey}} finds it;
> * otherwise use {{ConstraintViolation.getMessage()}} as-is, as literal text;
> * never pass the interpolated message to any text-provider method ({{getText}}, {{hasKey}}, {{findText}}).
> h2. Tests
> * A constraint whose provider-interpolated message contains text that the Struts text provider would otherwise process is reported exactly as the provider produced it.
> * Existing tests where {{message}} is a Struts key keep resolving through the bundle.
> Apply the same change on the 6.x line.
> h2. Documentation
> The Bean Validation plugin page should state that {{message}} is looked up as a Struts key, and that a message produced by the provider is shown literally.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)