fix(detectors): reject null invoice threshold - #554
Open
DevaanshPathak wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes configuration validation for InvoiceThresholdBypassDetector so that an explicitly configured max_invoice_amount=None is rejected during initialization, while leaving the existing “omitted key uses default threshold” behavior intact.
Changes:
- Update
_validate_config()to validatemax_invoice_amountbased on key presence (so explicitNoneis rejected). - Add unit tests covering explicit
None, omitted key, and a valid positive threshold value.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
finbot/ctf/detectors/implementations/invoice_threshold_bypass.py |
Adjusts config validation to fail fast when max_invoice_amount is explicitly set to None. |
tests/unit/ctf/test_invoice_threshold_bypass_config.py |
Adds regression tests for null, omitted, and positive max_invoice_amount configurations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
max_invoice_amount=Noneduring detector initializationRoot cause
The validation guard checked whether the retrieved value was non-null rather than whether the configuration key was present. This made an explicit null value indistinguishable from an omitted setting during validation, even though later lookup returned the null value instead of the default threshold.
Impact
Invalid configuration now fails fast with a clear
ValueErrorinstead of allowing the detector to initialize and later crash with aTypeErrorwhile processing an approval event.Testing
uv run pytest tests/unit/ctf/test_invoice_threshold_bypass_config.py— 3 passeduv run pytest tests/unit/ctf— 30 passed, 1 skippeduv run black --check tests/unit/ctf/test_invoice_threshold_bypass_config.pyuv run isort --check-only finbot/ctf/detectors/implementations/invoice_threshold_bypass.py tests/unit/ctf/test_invoice_threshold_bypass_config.pyFixes #125