fix(config): allow unsetting int/float config keys - #1320
Conversation
secator config unset <int-key> raised TypeError. Config.unset() calls set(key, None), and the type-coercion branch ran int(None)/float(None) before the set_partial handler could interpret None as "reset to default". Skip coercion when the value is None so the existing reset path runs. Closes freelabz#1052
Walkthrough
ChangesConfiguration unsetting
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unit/test_config.py (1)
87-98: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover the float and
Pathreset paths too.The PR objective includes integer, float, and
Pathkeys, but this test only exercises an integer. Add equivalent cases for a float and aPathfield so the sharedNonebypass is protected across all affected coercion branches.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/test_config.py` around lines 87 - 98, Extend test_unset_numeric_key to also unset and verify a float field and a Path field, covering their set, save, unset, and save cycles. Assert each key is removed from the persisted partial configuration and that Config.parse restores its corresponding default, preserving coverage of the shared None bypass across all coercion branches.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/unit/test_config.py`:
- Around line 87-98: Extend test_unset_numeric_key to also unset and verify a
float field and a Path field, covering their set, save, unset, and save cycles.
Assert each key is removed from the persisted partial configuration and that
Config.parse restores its corresponding default, preserving coverage of the
shared None bypass across all coercion branches.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f7debedf-6bde-40b8-bab9-3ba2dd034d2b
📒 Files selected for processing (2)
secator/config.pytests/unit/test_config.py
|
Thanks for this ! I just came back from vacations, will test this shorty and if all good add it to the next release ;) |
🤖 I have created a release *beep* *boop* --- ## [0.42.0](v0.41.0...v0.42.0) (2026-08-18) ### Features * **kev:** bundle a local CISA KEV mirror as an offline fallback ([#1331](#1331)) ([4f1ff5c](4f1ff5c)) * **output-types:** tag known-exploited vulnerabilities with `kev` ([#1319](#1319)) ([#1321](#1321)) ([fc1dcaf](fc1dcaf)) * **security:** non-interactive sudo password for headless workers ([#1335](#1335)) ([8aa0031](8aa0031)) ### Bug Fixes * **command:** don't crash on sudo prompt when TTY detection is wrong ([#1332](#1332)) ([#1333](#1333)) ([1ac6207](1ac6207)) * **command:** tty issue dumb terminals ([#1324](#1324)) ([f5af590](f5af590)) * **config:** allow unsetting int/float config keys ([#1320](#1320)) ([4f380c0](4f380c0)) * **docker:** bump alpine runtime to 3.23 (Go 1.25.10) for tool installs ([#1330](#1330)) ([fa6c647](fa6c647)) * **lint,test:** cli.py lint + deterministic empty-arg query test ([#1327](#1327)) ([7d79d91](7d79d91)) * **query:** allow empty ARG when a filter option is provided ([#1211](#1211)) ([6206b14](6206b14)) * **runners:** nested target filter dropping task inputs since [#1312](#1312) ([#1329](#1329)) ([9929ac3](9929ac3)) * **tasks:** force system OpenSSL in testssl to fix missing libproviders.so in Docker ([#1134](#1134)) ([b528cfb](b528cfb)) * **wpscan:** don't leak wpscan's version status into the finding status ([#1326](#1326)) ([428557b](428557b)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Closes #1052
secator config unset <int-key>(e.g.runners.progress_update_frequency) raisedTypeError: int() argument must be ... not 'NoneType'.Config.unset()callsset(key, None), but the type-coercion branch ranint(None)before theset_partialhandler could interpretNoneas "reset to default". Coercion is now skipped when the value isNone, so the existing reset path runs — same forfloat/Pathkeys.New
test_unset_numeric_keyfails with that exactTypeErrorwithout the one-line source change and passes with it.Summary by CodeRabbit
Bug Fixes
Tests