WW-2934 Skip field validators when a field has a conversion error (opt-in)#1810
Open
lukaszlenart wants to merge 5 commits into
Open
WW-2934 Skip field validators when a field has a conversion error (opt-in)#1810lukaszlenart wants to merge 5 commits into
lukaszlenart wants to merge 5 commits into
Conversation
…rror Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ersion error Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…opt-in flag Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ror skip exemption Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in validation behavior in Struts core to avoid redundant field-validator errors when a field already has a type-conversion error, while preserving the conversion validator’s message and leaving action-level validators unchanged.
Changes:
- Introduces the global constant
struts.validators.skipValidatorsOnConversionError(defaultfalse) and documents it indefault.properties. - Updates
DefaultActionValidatorManagerto skip non-conversionFieldValidators for fields present inActionContext.getConversionErrors()when the flag is enabled. - Adds core tests plus fixtures to cover default behavior, enabled behavior, and the
AnnotationActionValidatorManagerpath; includes design/plan docs underdocs/superpowers/.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| docs/superpowers/specs/2026-07-23-WW-2934-skip-validators-on-conversion-error-design.md | Design spec for the opt-in skip-on-conversion-error behavior. |
| docs/superpowers/plans/2026-07-23-WW-2934-skip-validators-on-conversion-error.md | Implementation plan documenting steps and test strategy. |
| core/src/main/java/org/apache/struts2/StrutsConstants.java | Adds the new STRUTS_VALIDATORS_SKIP_VALIDATORS_ON_CONVERSION_ERROR constant. |
| core/src/main/resources/org/apache/struts2/default.properties | Documents the new constant and its default value (false). |
| core/src/main/java/org/apache/struts2/validator/DefaultActionValidatorManager.java | Injects the flag and implements the validator-skip guard based on conversion errors. |
| core/src/test/java/org/apache/struts2/validator/ConversionErrorSkipAction.java | Test fixture action used to validate conversion-error skipping behavior. |
| core/src/test/resources/org/apache/struts2/validator/ConversionErrorSkipAction-validation.xml | Test fixture validation rules (conversion + required + unrelated field + action-level validator). |
| core/src/test/java/org/apache/struts2/validator/DefaultActionValidatorManagerTest.java | Adds coverage for flag off/on behavior and annotation manager path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lukaszlenart
requested review from
aleksandr-m,
cnenning,
jogep,
kusalk,
rgielen,
sdutry and
yasserzamani
July 23, 2026 19:57
…er nested field skip Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
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-2934
Problem
When a field fails type conversion (e.g. a user types
oneinto anInteger agefield), the user sees two errors for the same field:ConversionErrorInterceptor(which runs before validation in the default stack).required), because binding failed and the field holds its default value.Once a value could not be converted, the field's remaining validators are operating on a value the user never entered, so they should be skipped.
Change
Adds an opt-in global constant
struts.validators.skipValidatorsOnConversionError(defaultfalse— zero behavior change for existing apps).When enabled,
DefaultActionValidatorManagerskips a field's remaining validators once that field has an entry inActionContext.getConversionErrors(), with two guarantees:conversionvalidator (ConversionErrorFieldValidator) still runs, so its (optionally custom) message is preserved.The guard sits in the single
validate(...)choke point that both XML- and annotation-driven validation funnel through, and reuses the already-computed full field name (so nested/indexed fields match correctly).Tests
DefaultActionValidatorManagerTestgains coverage for: flag off → both errors (unchanged behavior); flag on → redundant validator skipped, conversion message retained; unrelated field still validated; action-level validator unaffected; and the same skip firing through the defaultAnnotationActionValidatorManager. Fullvalidatorpackage suite: 172/172 green.Note
This branch also includes the design spec and implementation plan under
docs/superpowers/. Happy to drop those commits if you'd prefer a code-only PR.🤖 Generated with Claude Code