Skip to content

hard-fail on legacy module options dict; version preload cache - #3119

Merged
liquidsec merged 1 commit into
preset-validationfrom
legacy-options-hard-fail
May 21, 2026
Merged

hard-fail on legacy module options dict; version preload cache#3119
liquidsec merged 1 commit into
preset-validationfrom
legacy-options-hard-fail

Conversation

@liquidsec

Copy link
Copy Markdown
Collaborator

Summary

  • Reject pre-3.0 `options = {...}` / `options_desc = {...}` dicts at preload time with a copy-pasteable migration recipe. Previously these dicts were silently ignored: defaults disappeared and setting them via `-c` or YAML emitted misleading "did you mean ...?" suggestions pointing at unrelated modules.
  • Fold a new `PRELOAD_CACHE_VERSION` constant into the per-module cache key so preloader-logic changes (this one, future ones) auto-invalidate stale cache entries instead of bypassing the new behavior.
  • BBOTError raised from `preload_module` now prints cleanly via a dedicated handler in `preload()` (no Python traceback noise on user-facing migration errors).

Repro before / after

A user module that uses the legacy pattern:

```python
class legacy_user_mod(BaseModule):
watched_events = ["DNS_NAME"]
options = {"my_api_key": "", "max_results": 100}
options_desc = {"my_api_key": "API key", "max_results": "Max results"}
```

Before: module loads with all option defaults silently dropped; setting them in YAML produces `[WARN] Could not find config option "modules.legacy_user_mod.my_api_key". Did you mean "modules.dehashed.api_key"?`

After:

```
[CRIT] Module "legacy_user_mod" (/path/legacy_user_mod.py:11) declares a legacy `options` dict, which is no longer supported in BBOT 3.0+.

Replace the `options` / `options_desc` dicts with a nested
`class Config(BaseModuleConfig)` schema. For example:

from bbot.core.config.models import BaseModuleConfig, Field

class legacy_user_mod(BaseModule):
    ...
    class Config(BaseModuleConfig):
        api_key: str = Field(\"\", description=\"API key\", sensitive=True)
        max_results: int = Field(100, description=\"Max results to return\")

```

Tests

`test_legacy_options_dict_rejected` covers:

  • old-style `options=` dict raises `BBOTError` with the migration text
  • old-style `options_desc=` only also raises
  • new-style `class Config(BaseModuleConfig)` still preloads cleanly

Follow-up (separate PR)

`docs/dev/module_howto.md` still shows the legacy `options = {...}` pattern at lines 26 and 123-138. That's part of a planned "3.0 Breaking Changes" docs section.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Performance Benchmark Report

⚠️ No current benchmark data available

This might be because:

  • Benchmarks failed to run
  • No benchmark tests found
  • Dependencies missing

@codecov

codecov Bot commented May 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90%. Comparing base (1a119e8) to head (2bc1f4b).
⚠️ Report is 2 commits behind head on preset-validation.

Files with missing lines Patch % Lines
bbot/core/modules.py 82% 3 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##           preset-validation   #3119   +/-   ##
=================================================
+ Coverage                 90%     90%   +1%     
=================================================
  Files                    451     451           
  Lines                  39771   39806   +35     
=================================================
+ Hits                   35643   35675   +32     
- Misses                  4128    4131    +3     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@liquidsec
liquidsec requested a review from ausmaster May 21, 2026 19:42
@liquidsec
liquidsec merged commit bacc671 into preset-validation May 21, 2026
18 checks passed
@liquidsec liquidsec mentioned this pull request Jun 9, 2026
@ausmaster
ausmaster deleted the legacy-options-hard-fail branch June 11, 2026 01:27
@ausmaster ausmaster added this to the BBOT 3.0 - blazed_elijah milestone Jun 26, 2026
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.

2 participants