Repository navigation
WW-5818 Optionally fail a validator whose param cannot be converted - #2198
Open
emilhuseyn wants to merge 1 commit into
Open
emilhuseyn wants to merge 1 commit into
emilhuseyn wants to merge 1 commit into
Conversation
…not be converted Adds struts.validators.failOnUnconvertibleParam (default false). When set, DefaultValidatorFactory throws a ConfigurationException naming the validator, the param, the value and the cause, instead of logging the conversion error and building the validator with the param unset, which turns a range check off. Only params with a writable property count, as for the WW-5819 logging. 8.0.0 can flip the default.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes WW-5818
Since WW-5819,
factory.DefaultValidatorFactorylogs a validator param that cannot be converted (WARN, ERROR in devMode) and builds the validator with the param unset. For a range bound that still turns the check off, for example<param name="min">01/02/2026</param>onlocaldate.The ticket targets 8.0.0 because failing here breaks applications whose misconfigured param has gone unnoticed.
mainis still 7.6.0, so this follows the pattern ofstruts.parameters.requireAnnotations.enforceOnResolvedMember: the new behaviour sits behind a constant that defaults to false, and 8.0.0 can flip the default with a migration note.struts.validators.failOnUnconvertibleParam(StrutsConstants.STRUTS_VALIDATORS_FAIL_ON_UNCONVERTIBLE_PARAM), documented indefault.properties, defaultfalse.setParamthrows aConfigurationExceptionnaming the validator class, the param, the value and the root cause, instead of logging.validator.DefaultValidatorFactory.getValidatoralready wraps that in aStrutsExceptioncarrying theValidatorConfig, so the error points at the XML location.methodNamerouting param the annotation builder adds, and misspelled param names, stay silent as before. The WW-5819 Log a validator param that fails type conversion #2062 description says misspelled names belong with WW-5818; I left them out because telling them apart from routing params needs a list of those params, and I would rather ask first. Happy to add it here or in a follow-up.Validators are built from the cached configs each time an action is validated, so with the constant on a bad param fails that action's validation on every request rather than failing at startup. That is still a visible error where today the check is skipped without one.
Tests in
DefaultValidatorFactoryTest, with the constant on:min=01/02/2026onlocaldateandmin=abconintfail with aStrutsExceptionwhose cause is aConfigurationExceptionnaming the param and the valueminand arequiredvalidator with themethodNameparam still build, with nothing loggedThe two failing-case tests fail on
main(the validator is built) and pass with the change.DefaultValidatorFactoryTestand the other*Validator*and*Validation*tests pass locally on JDK 21, along with the fullcoresuite.Not in this PR: flipping the default and the migration guide entry, which belong with the 8.0.0 branch.
🤖 Generated with Claude Code