[
https://issues.apache.org/jira/browse/WW-5757?focusedWorklogId=1045917&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1045917
]
ASF GitHub Bot logged work on WW-5757:
--------------------------------------
Author: ASF GitHub Bot
Created on: 06/Oct/26 12:42
Start Date: 06/Oct/26 12:42
Worklog Time Spent: 10m
Work Description: lukaszlenart merged PR #1989:
URL: https://github.com/apache/struts/pull/1989
Issue Time Tracking
-------------------
Worklog Id: (was: 1045917)
Time Spent: 1.5h (was: 1h 20m)
> 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
>
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> {{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)