Default the name-validation.enabled placeholder in NameValidator - #1529
Open
rq-jwhitlock wants to merge 1 commit into
Open
Default the name-validation.enabled placeholder in NameValidator#1529rq-jwhitlock wants to merge 1 commit into
rq-jwhitlock wants to merge 1 commit into
Conversation
NameValidator reads conductor.app.workflow.name-validation.enabled through a bare @value with no default. Because the validator lives in conductor-common, Hibernate Validator instantiates it inside every consuming application's context, not only conductor-server's, so any consumer that does not define the property fails bean creation with a PlaceholderResolutionException. The failure is lazy: it happens on the first request that triggers bean validation rather than at startup, so it presents as a 500 on workflow or task registration in an application that started cleanly and reports healthy. That makes it easy to misattribute to the caller's payload. Defaults to false, matching the value conductor-server already ships in its application.properties, so behaviour is unchanged for anyone setting it explicitly. Adds NameValidatorPlaceholderTest, which builds a context that omits the property. The existing NameValidatorTest cannot cover this because it assigns the field via ReflectionTestUtils and so never resolves the placeholder; reverting the default leaves those tests green while the new one fails with the original BeanCreationException.
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.
Default the
name-validation.enabledplaceholder inNameValidatorProblem
ValidNameConstraint.NameValidatorreads its configuration through a bare@Valuewith no default:NameValidatorlives in conductor-common, so Hibernate Validator instantiates it inside every consuming application's context — not onlyconductor-server's.conductor-serverdefines the property in its ownapplication.properties, but an application that embeds conductor-common (or conductor-core / conductor-rest) and supplies its own configuration has no reason to know the key exists. When it doesn't, bean creation fails:The failure is lazy, which is what makes it unpleasant to diagnose. Hibernate Validator creates the validator on first use, so nothing fails at startup — the application boots cleanly and reports healthy. The error appears only on the first request carrying a
@ValidNameConstraintfield, i.e. as a 500 onPOST /api/metadata/workflow(or the task-definition equivalent). Because the response is a generic 500 on a registration call, it reads as a malformed payload rather than a configuration problem.This is the only bare
@Valuewithout a default in Conductor's main source.Fix
falseis the valueconductor-serveralready ships in itsapplication.properties, so behaviour is unchanged for anyone who sets the property, and consumers that don't set it now inherit conductor-server's own default instead of a crash.Tests
Adds
NameValidatorPlaceholderTestwith two cases:validatorIsConstructableWhenPropertyIsUndefined— builds a context that omits the property and asserts the bean is created, with validation defaulting to off.explicitPropertyStillTakesEffect— sets the property totrueand asserts an invalid name is still rejected, so the default cannot mask a configured value.The existing
NameValidatorTestcannot catch this: it assigns the field viaReflectionTestUtils.setField, which bypasses placeholder resolution entirely.I verified the new test is load-bearing by reverting the default —
NameValidatorPlaceholderTest.validatorIsConstructableWhenPropertyIsUndefinedthen fails with the originalBeanCreationException, while all three pre-existingNameValidatorTestcases stay green.Verified on
main@1bad2c88d:conductor-common109 tests / 0 failures,./gradlew :conductor-common:buildsuccessful,spotlessCheckclean.Notes
Found while running a Spring Boot application at ReliaQuest that embeds conductor-common with its own configuration; a 500 on workflow registration was the only symptom. No API change, and no behavioural change for existing deployments.