Skip to content
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

Make raise_on_notset default to True with environment variable override #3

Conversation

flipdazed
Copy link
Contributor

@flipdazed flipdazed commented Feb 8, 2025

This PR changes how the rule engine handles missing fields by making it stricter by default while maintaining flexibility for users who need different behaviour.

Key changes:

  1. Changed _raise_on_notset to default to True instead of False
  2. Added environment variable RULE_ENGINE_RAISE_ON_NOTSET to globally control this behavior
    • Set to "true" or "1" to enable raising (default)
    • Set to any other value to disable raising
  3. Maintained the ability to override per-rule using __raise_on_notset parameter
  4. Updated tests to:
    • Explicitly set __raise_on_notset=False where needed
    • Add comprehensive test coverage for environment variable behavior
    • Verify interaction between env var and per-rule settings

This change makes the behaviour more explicit and safer by default, as it will now alert users when they try to evaluate rules against missing fields rather than silently failing. Users who need the old behavior can either:

  • Set RULE_ENGINE_RAISE_ON_NOTSET=false globally
  • Set __raise_on_notset=False on specific rules

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (ade82bd) to head (01946be).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##              main        #3   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines          353       371   +18     
=========================================
+ Hits           353       371   +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@flipdazed flipdazed changed the title Alex/key 2411 misconfiguration passes by default bad for fatf Make raise_on_notset default to True with environment variable override Feb 8, 2025
@flipdazed flipdazed changed the title Make raise_on_notset default to True with environment variable override Make raise_on_notset default to True with environment variable override Feb 8, 2025
@biagiodistefano biagiodistefano merged commit 80b9b44 into biagiodistefano:main Feb 10, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants