New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audit validation tags for configuration properties #1491
Comments
@bluekeyes We should certainly get better at validating configurations. Since there are a lot of options, it's easy to forget something and make a mistake, so I think we should look holistically at the configuration. For example, if What do you think? |
When it's missing, we write a short message saying so, and when it's invalid, we do approximately the same thing. Athens has a lot of configuration options, so it's naturally easy to get them wrong or forget something. Nicer error messages should help. If this code is acceptable, I'd like to apply it to a few other config values (in a follow-up PR) that are easy to get wrong. ref gomods#1491, since this checks existence and validates values for download mode, and also reports errors in a more human-friendly way cc/ @bluekeyes
Yeah, it makes sense to me that the application would need a way to validate relationships between properties and that that would provide a better user experience than just saying if an option is required or not. From a pure code perspective, I personally find it a bit confusing when there are multiple validation methods at play in a project, so long term, I think it could be valuable to decide on when to use the |
@bluekeyes I don't have any experience with validator.v9, but it looks nice. The idea I have in mind is to centralize all validation of configuration in one place in the code, regardless of where the configuration values came from - file, environment variables, or anywhere else we define later on. Ideally, the validations would come with good error messages too, when Athens is misconfigured. I'll check out validator.v9 to see if I can get it working in #1492 too - thanks! |
Is your feature request related to a problem? Please describe.
For some properties (I hit it on
DownloadMode
, but may apply to others), the zero value is invalid and the property is effectively required, but is not marked as required for validation.Describe the solution you'd like
Audit the configuration type definitions to make sure the validation tags are correct for properties. I think the
required
tag is the most relevant, since a missing required property gives a clear error at startup, while the zero value for the type may give a confusing error later on.Describe alternatives you've considered
Introduce another method to validate configuration. This seems non-ideal, since validation tags are already used for some properties.
Additional context
This issue is split out of #1336, which has some additional information.
The text was updated successfully, but these errors were encountered: