Lukasz Lenart created WW-5818:
---------------------------------

             Summary: A validator param that fails type conversion is silently 
ignored instead of failing the configuration
                 Key: WW-5818
                 URL: https://issues.apache.org/jira/browse/WW-5818
             Project: Struts 2
          Issue Type: Bug
          Components: XML Validators
            Reporter: Lukasz Lenart
             Fix For: 8.0.0


h2. Problem

{{DefaultValidatorFactory}} builds each validator through 
{{ObjectFactory.buildValidator}}, which sets the configured params with type 
conversion errors swallowed. A param that cannot be converted is left unset, 
without any error. For a range bound, that turns the check off:

{code:xml}<field-validator type="localdate">
    <param name="min">01/02/2026</param>  <!-- not an ISO date -->
</field-validator>
{code}

{{min}} ends up {{null}}, so the validator never checks the lower bound. 
Nothing is logged and the application starts normally. Found while working on 
WW-5816 ({{localdate}}). The same path applies to every validator built from 
XML, for example {{<param name="min">abc</param>}} on {{int}}, or a bound in 
the wrong locale format on {{date}}.

Annotation-configured validators behave differently for {{localdate}}: 
{{AnnotationValidationConfigurationBuilder}} parses its bounds with 
{{LocalDate.parse}} and fails when the validators are built.

h2. Proposal

Make a validator param that fails conversion an error when the validator is 
built: a {{ConfigurationException}} (or {{StrutsException}}) naming the 
validator type, the param and the value, instead of silently leaving it unset.

h2. Compatibility

Applications with a misconfigured param that has gone unnoticed would start 
failing. That makes this a breaking change, so it targets 8.0.0 and needs a 
migration guide entry. An interim option for 7.x would be a WARN log, plus an 
ERROR in devMode, for the swallowed conversion error.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to