-
Notifications
You must be signed in to change notification settings - Fork 706
config: don't apply values that fail validation #29117
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
base: dev
Are you sure you want to change the base?
config: don't apply values that fail validation #29117
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug in config_store::read_yaml() where property values would be incorrectly applied even when custom validation failed. The fix ensures that invalid configuration values are rejected and properties retain their default values, matching the behavior for type conversion errors.
Key changes:
- Moved
set_value()call inside the else branch so values are only applied when validation succeeds - Added comprehensive test coverage for validation failure scenarios including optional properties, required properties, and throwing validators
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/v/config/config_store.h | Fixed validation logic to prevent setting values when custom validators fail |
| src/v/config/tests/config_store_test.cc | Added test fixtures and test cases for validation failure scenarios |
Comments suppressed due to low confidence (1)
src/v/config/tests/config_store_test.cc:16
- Two header includes were removed (#include <seastar/core/thread.hh> and #include ) but they may still be needed elsewhere in the file. Verify that these headers are truly unused throughout the entire file before removing them.
#include <seastar/testing/thread_test_case.hh>
Retry command for Build#78392please wait until all jobs are finished before running the slash command |
dfed747 to
4b953f7
Compare
rockwotj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a little worried if there are people taking advantage of this validation being skipped in the config bootstrapping. I think doing the conservative thing is right here (And I think to answer your question about why the config system behaves in a certain way is because it was done very quickly).
|
todo for myself: add a test that shows that for bounded properties instead of ignoring the value we actually bound it and apply it. better backwards compat and sensible behavior. |
Test read_yaml behavior with validator errors, type mismatches, and throwing validators.
Previously, config_store::read_yaml() would apply property values even when custom validation failed, only recording the error. This meant invalid configuration values would silently take effect despite being reported as errors. This behavior was also inconsistent: conversion exceptions (e.g., YAML::BadConversion) correctly prevented values from being set, but custom validator errors did not. Fix by moving set_value() inside the else branch so values are only applied when validation succeeds. This has two effects: 1. Optional properties now correctly retain their default value when validation fails. 2. Required properties now correctly throw std::invalid_argument when validation fails. Previously, the throw logic was bypassed because ok was set to true even after validation errors. Note: It's unclear why we don't stop server startup on invalid optional config values. To avoid breaking something I don't fully understand, this change takes the conservative approach of retaining defaults.
4b953f7 to
2edb60e
Compare
Retry command for Build#78435please wait until all jobs are finished before running the slash command |
config_store::read_yaml()would apply property values even when customvalidation failed, only recording the error. This meant invalid configuration
values would silently take effect despite being reported as errors.
This behavior was also inconsistent: conversion exceptions (e.g.,
YAML::BadConversion) correctly prevented values from being set, butcustom validator errors did not.
The fix moves
set_value()inside the else branch so values are only appliedwhen validation succeeds:
Optional properties now correctly retain their default value when validation
fails.
Required properties now correctly throw
std::invalid_argumentwhenvalidation fails. Previously, the throw logic was bypassed because
okwasset to true even after validation errors.
It's unclear why we don't stop server startup on invalid optional config values.
To avoid breaking something I don't fully understand, this change takes the
conservative approach of retaining defaults.
Backports Required
Release Notes
Bug Fixes