VaultEncryptionHelper's validation exception message should include all validation problems #783
Labels
enhancement
A request for change or improvement to an existing feature
Milestone
The
ValidationEncryptionHelper
constructor validates its arguments. When it validates theVaultConfiguration
it throws anIllegalArgumentException
for the first problem it finds. So, if there is more than one problem, the calling code won't know that and will only know about the first problem.It would be much better to validate the entire object and provide a message containing all the validation errors in the
IllegalArgumentException
's message.VaultConfiguration
uses the@NotBlank
Java/Jakarta Beans Validation annotation on its properties, though it does not validate that those paths actually exist. However,ValidationEncryptionHelper
does not use Beans Validation to validate, but checks the properties itself. IIRC the Beans Validation annotations were mainly to allow theVaultConfiguration
to be validated at (Dropwizard) service startup, since it would be part of the service configuration class. The more involved validation insideValidationEncryptionHelper
also verifies that the specified files (e.g. theansible-vault
executable and the vault password file) actually exist.Regardless of how we choose to implement the validation in
ValidationEncryptionHelper
, theIllegalArgumentException
should contain all the problems.The text was updated successfully, but these errors were encountered: