fix(cli): Honor excluded_attributes from config file#306
Conversation
27ba226 to
641654b
Compare
AgentReady Code Review — PR #306fix(cli): Honor excluded_attributes from config file SummaryThis PR correctly fixes issue #302 by merging AgentReady Attribute Impact
No regressions to assessed attributes. Code Analysis✅ Correctness —
|
| Test | Scenario | Status |
|---|---|---|
test_run_assessment_excludes_attributes_from_config_issue_302 |
Config-only exclusion | ✓ |
test_run_assessment_merges_cli_and_config_exclusions_issue_302 |
CLI + Config merged | ✓ |
test_run_assessment_validates_config_excluded_attributes_issue_302 |
Invalid ID in config rejected | ✓ |
Test gap: The verbose logging condition was modified (removed the redundant and exclude guard), but no test validates that verbose=True echoes exclusions when they come from config alone. Low risk since the logic is simple, but the behavioral change is untested.
Security
No security concerns. Validation against valid_ids protects against arbitrary attribute IDs from config files. No shell execution, SQL, or untrusted data paths are involved in the changed code.
Verdict
Approve with minor notes. The bug fix is correct, well-tested (5:1 test-to-production-code ratio), and consistent with existing patterns in the codebase. Two non-blocking items:
click.BadParameteris semantically wrong for config file validation errors —click.ClickExceptionwould be more accurate- Verbose logging behavior change is untested (low risk)
Review generated by AgentReady code review skill • Self-assessment: 80.0/100 Gold
AgentReady Code Review: PR #306 — fix(cli): Honor excluded_attributes from config fileReviewer: AgentReady automated review SummaryThis PR fixes a real bug (#302): Code Quality
The logic change is clean and idiomatic: all_exclusions = set(exclude or [])
if config and config.excluded_attributes:
all_exclusions.update(config.excluded_attributes)
The verbose output change from Minor: Minor: Verbose output doesn't distinguish source. Note: Test CoverageThree regression tests added, all with clear docstrings explaining the issue context.
Minor: assessors = call_args[0][0] # First positional argumentIf AgentReady Attribute Compliance
SecurityNo security concerns. The validation path ( VerdictThe fix is correct, well-scoped, and meaningfully tested. The two minor issues (error type and fragile test indexing) are non-blocking. Recommend merging after the draft is finalized and integration tests are confirmed passing. |
641654b to
c640bde
Compare
📈 Test Coverage Report
Coverage calculated from unit tests only |
Code Review - Follow-up to Automated ReviewsThis review follows the two automated comments posted at 22:17Z and 22:19Z. The latest commit (pushed at 22:29Z) addressed the concerns raised in those earlier reviews, and the overall direction here is solid. The core bug fix is correct: What Was Addressed in the Latest Commit
Good follow-through on the review feedback. Remaining Issues1. Fragile mock call introspection (
|
The excluded_attributes option in configuration files was being ignored. Only the --exclude CLI flag worked. This fix merges exclusions from both sources (CLI and config) before filtering assessors, and adds validation so invalid attribute IDs in config files now produce clear error messages. Changes: - Merge CLI --exclude and config.excluded_attributes into a single set - Validate all exclusions against valid attribute IDs - Use ClickException for config errors (clearer than BadParameter) - Report errors from both sources together when both have invalid IDs - Add 4 regression tests for issue ambient-code#302 - Fix E2E test to use valid attribute ID (openapi_specs not repomix_config) - Use modern mock API (.args[0]) for more robust test introspection - Use CliRunner for reliable Click output capture in verbose test Fixes ambient-code#302 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
c640bde to
5cece06
Compare
Outdated review (click to expand)🤖 AgentReady Code ReviewPR: #306 fix(cli): Honor excluded_attributes from config file
What this PR does wellThe core fix is correct:
🟡 Major Issues (Confidence 80-89) - Manual Review Required1. Combined-error code path is untestedAttribute: Issue Details: Four tests cover these paths:
The untested path is the sub-clause inside if invalid_from_cli:
msg = f"Invalid attribute ID(s): {', '.join(sorted(invalid_from_cli))}."
if invalid_from_config: # ← this sub-clause has no test
msg += f" Also invalid in config file: {', '.join(sorted(invalid_from_config))}."
msg += f" Valid IDs: {', '.join(sorted(valid_ids))}"
raise click.BadParameter(msg)If this sub-clause is deleted or broken, no test will catch the regression. Remediation: # Add a 5th test for the mixed-source invalid ID case:
# def test_run_assessment_validates_mixed_source_invalid_attrs_issue_302
# Setup: config with "invalid_config_attr", CLI exclude=["invalid_cli_attr"]
# Assert: click.BadParameter raised
# Assert: "invalid_cli_attr" in error message
# Assert: "Also invalid in config file" in error message
# Assert: "invalid_config_attr" in error message
pytest tests/unit/cli/test_main.py::TestRunAssessmentCommand -v🔵 Minor Issues - Low Priority2. Verbose output does not distinguish exclusion sourceAttribute: N/A (UX improvement, not a scored attribute) The merged verbose message Low priority — the fix is functionally correct; this is a polish item for a follow-up. Summary
🤖 Generated with Claude Code If this review was useful, react with 👍. Otherwise, react with 👎. |
Code Review: fix(cli): Honor excluded_attributes from config fileOverall: This is a well-targeted bug fix that correctly addresses the root cause. The implementation is sound and the regression tests are thorough. A few minor issues worth addressing before merge. Issues1. Dead Code Guard (minor)
config_exclusions = set(config.excluded_attributes) if config else set()
config_exclusions = set(config.excluded_attributes)2. Untested Error Path (minor)The mixed invalid IDs case — where both CLI and config have invalid IDs simultaneously — has a specific code path (lines 286-291) that is never exercised by the 4 new tests. Specifically, the 3. Valid IDs Verbose in Error Messages (minor)Error messages include the full sorted list of all valid attribute IDs (31+ items), e.g.: This can produce multi-line terminal output. Consider appending Strengths
SummaryThe bug fix logic is correct and the tests cover the primary scenarios well. The three items above are all minor — the dead code guard is the easiest to clean up before merge. |
… test - Simplify set creation: use inline conditional instead of ternary - Unify error handling: use ClickException for all validation errors - Add test for mixed-source invalid IDs (CLI + config together) Addresses review feedback on PR ambient-code#306. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
🎉 This PR is included in version 2.28.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Description
fix(cli): Honor excluded_attributes from config file
Type of Change
Related Issues
Fixes #302
Changes Made
The excluded_attributes option in configuration files was being ignored. Only the --exclude CLI flag worked. This fix merges exclusions from both sources (CLI and config) before filtering assessors, and adds validation so invalid attribute IDs in config files now produce clear error messages.
Testing
pytest)Checklist