-
Notifications
You must be signed in to change notification settings - Fork 253
feat(config): Reject invalid configuration combinations #2077
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
Conversation
- Add validation to `EnabledPlugin` to reject mutually exclusive options - `package_file` and `extra_packages` cannot be used together - Provide clear error message when both options are specified - Add comprehensive unit tests and integration tests - Validation occurs during configuration parsing/post-processing Fixes #1946 Co-authored-by: brynary <[email protected]>
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
Fix invalid configuration combinations in qlty.toml
by rejecting cases where both package_file
and extra_packages
are set on the same plugin.
- Add
EnabledPlugin::validate
to enforce mutual exclusion - Hook validation into the builder with contextual error wrapping
- Cover validation logic via unit tests and integration tests in the builder
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
qlty-config/src/config/plugin.rs | Introduce validate on EnabledPlugin and add unit tests |
qlty-config/src/config/builder.rs | Call validate during build and add integration tests |
Comments suppressed due to low confidence (1)
qlty-config/src/config/builder.rs:208
- Add an integration test that asserts the final error includes the context prefix
Invalid configuration for plugin '...
to verify the custom context is actually applied.
enabled_plugin.validate().with_context(|| {
@claude the tests are failing, we need to fix those Also make sure to run |
Claude finished @brynary's task —— View job Todo List
Issues FixedTest failures: The tests were calling Formatting: Fixed formatting issues using rustfmt on both changed files. Changes Made
The tests should now pass because they're properly calling the validation logic that checks for mutually exclusive |
- Fix test methods to call toml_to_config instead of parse_toml_as_config - Make toml_to_config public for testing - Fix formatting with rustfmt Co-authored-by: brynary <[email protected]>
@claude Use |
Claude finished @brynary's task —— View job Todo List
Formatting Issues FixedSuccessfully ran
The formatting issues should now be resolved and the qltysh bot should no longer report blocking formatting errors. |
Co-authored-by: brynary <[email protected]>
@claude fix the unit tests so they pass when we run |
Claude finished @brynary's task —— View job Todo List
Issues FixedTest failures: The main issue was that the test was checking Changes made:
The tests now pass because they properly examine the full error chain where the detailed validation message is preserved, rather than just the top-level context message. The |
- Updated test to check full error chain instead of just top-level message - Changed context message from "Invalid configuration" to "Configuration error" - Fixed test assertions to properly validate mutually exclusive options error Co-authored-by: brynary <[email protected]>
Diff Coverage for macos-15: The code coverage on the diff in this pull request is 100.0%. Total Coverage for macos-15: This PR will increase coverage by 0.27%. File Coverage Changes
🛟 Help
|
Diff Coverage for ubuntu-latest: The code coverage on the diff in this pull request is 100.0%. Total Coverage for ubuntu-latest: This PR will increase coverage by 0.27%. File Coverage Changes
🛟 Help
|
@claude this is looking good. Can you please add one more validation rule?
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
@claude this is looking good. Can you please add one more validation rule?
|
Claude finished @brynary's task —— View job Todo List
Changes MadeSuccessfully added the validation rule that New validation logic:
Comprehensive testing:
Test coverage:
The validation occurs during configuration parsing and provides helpful error messages to guide users toward correct configuration. |
- Add validation in EnabledPlugin::validate() to enforce that package_filters can only be used when package_file is also specified - Add comprehensive unit tests for all combinations of package_filters and package_file - Add integration tests in builder.rs to verify end-to-end validation - Provide clear error messages when validation fails Co-authored-by: brynary <[email protected]>
Fixes #1946
This PR implements validation to reject invalid configuration combinations in qlty.toml files.
Changes
EnabledPlugin
to detect mutually exclusive optionspackage_file
andextra_packages
cannot be used togetherTesting
The implementation includes tests that verify:
package_file
extra_packages
Generated with Claude Code