Fix silent key drop and EOFError in configure_module --set/non-interactive - #47
Open
elhoim wants to merge 1 commit into
Open
Fix silent key drop and EOFError in configure_module --set/non-interactive#47elhoim wants to merge 1 commit into
elhoim wants to merge 1 commit into
Conversation
…ctive configure_module() only checked declared config_keys against --set, so a mistyped or unsupported key (e.g. api_key vs apikey) was silently discarded instead of erroring. Any declared key not covered by --set still called input(), which raises EOFError with no stdin (e.g. under cron); that exception propagated up and was caught by main()'s broad except, returning 1 before save_config() ran and discarding any keys already collected in that call. Fix: - configure_module() now raises ValueError naming any --set key(s) that are not in the module's declared config_keys, instead of dropping them. - Add a --non-interactive flag. When set, configure_module() checks for missing required keys up front and raises ValueError naming them, instead of calling input() and risking EOFError. This gives README's 'Non-interactive configuration' a way to actually run under cron/unattended contexts.
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.
Finding 15 (Medium) —
bin/cli.py:688-704Problem
configure_module iterates only the module's declared config_keys, so a --set key the module does not declare (api_key vs apikey) is silently discarded; and any declared key not supplied still calls input(), which raises EOFError under cron - caught at :871, returning 1 with save_config (:716) never reached, losing keys already collected. README calls this 'Non-interactive configuration'.
Fix
configure_module() (bin/cli.py) silently discarded any --set KEY=VALUE whose key wasn't in the module's declared config_keys (e.g. api_key vs apikey), and for any declared key not covered by --set it called input(), which raises EOFError under cron/no-stdin contexts - caught by main()'s broad except, returning 1 before save_config() ran, losing any keys already collected. This broke the README's documented "Non-interactive configuration" use case. Fix: configure_module() now raises ValueError naming any unrecognized --set key(s) instead of dropping them, and a new --non-interactive flag makes it check for missing required keys up front and fail immediately (naming them) instead of calling input().
Verification
Reproduced against the unmodified code at
9b8c605, then re-checked after the change.Before
After
python bin/cli.py --helpexits 0 and the module still imports cleanly. Verification was performed offline against the pure functions — no runningmisp-modulesinstance is required.Branched from
9b8c605. This PR addresses only this finding; the other findings from the same review are in separate PRs, so they will need rebasing against each other as they merge.🤖 Generated with Claude Code
https://claude.ai/code/session_01DYX4TKA5inzByJ4qGWKjqh