test(guardrails): add unit tests for config validation#323
Merged
Conversation
) Add config-level unit tests for ProviderType serde, PhaseConfig defaults/overrides/deny_unknown_fields, and AiGuardrailsConfig serde validation. Strengthen the body_mode test to assert the exact 1 MiB StreamBuffer limit. Convert dead_code expects on PhaseConfig fields to cfg_attr(not(test)) so tests can read the fields. Signed-off-by: Sébastien Han <seb@redhat.com>
franciscojavierarceo
approved these changes
Jul 9, 2026
praxis-bot
reviewed
Jul 9, 2026
praxis-bot
left a comment
Collaborator
There was a problem hiding this comment.
Review: test(guardrails): add unit tests for config validation
Well-scoped PR. The cfg_attr(not(test), expect(dead_code, ...)) pattern is correct, the assert_eq! strengthening in body_mode_is_stream_buffer is a nice improvement, and the new config tests cover the important serde paths (defaults, custom values, deny_unknown_fields, missing required fields).
| Severity | File | Finding |
|---|---|---|
| Medium | tests.rs:358-359 |
Missing assertion messages in guardrails_config_with_phase_overrides |
| Medium | mod.rs:15-17 |
Unused lint suppressions added to blanket allow |
Note on mod.rs: The three new suppressions (expect_used, needless_raw_strings, needless_raw_string_hashes) are not triggered by any code in the test module — no test uses .expect(), and every raw string legitimately contains embedded " characters. Consider adding suppressions only when code that needs them arrives, to keep the allow list honest.
3 tasks
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.
Summary
filters/src/guardrails/config.rs)body_mode_is_stream_buffertest to assert exactmax_bytesvalue#[cfg_attr(not(test), expect(dead_code, ...))]for fields only read in testsCloses #282
Test plan
cargo test -p praxis-ai-filters -- guardrails— all tests passmake lint— clippy + nightly rustfmt clean