MOD-14486: Fix crash on odd word count in space-separated moduleArgs#244
Open
ofiryanai wants to merge 2 commits intoRedisLabsModules:masterfrom
Open
MOD-14486: Fix crash on odd word count in space-separated moduleArgs#244ofiryanai wants to merge 2 commits intoRedisLabsModules:masterfrom
ofiryanai wants to merge 2 commits intoRedisLabsModules:masterfrom
Conversation
fix_modulesArgs crashed with sys.exit(1) when a space-separated moduleArgs string had an odd number of words. This is a valid scenario when module args have single-word flags or multi-word values. Instead of crashing, fall back to treating the string as a single arg (the pre-v0.7.22 behavior) when the word count is odd.
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.
Problem
PR #243 (v0.7.22) added logic to parse space-separated moduleArgs as key-value pairs. However, it calls
sys.exit(1)when the word count is odd. This is too aggressive — legitimate module args can have non-paired structures.Concrete example
RediSearch's test harness sets MODARGS defaults with semicolons:
A per-test
Env()call uses space-separated args without semicolons:When
fix_modulesArgsprocesses the per-test string, it sees no semicolons and enters the new code path from PR #243. It counts words:FORK_GC_CLEAN_NUMERIC_EMPTY_NODES(module name/prefix)_FORK_GC_CLEAN_NUMERIC_EMPTY_NODES(config key)true(config value)That's 3 words (odd) →
sys.exit(1)→ entire test suite crashes.The assumption that all space-separated args are strictly
KEY VALUE KEY VALUEpairs is incorrect. Args can have module prefixes, single-word flags, or multi-word values.Fix
Instead of crashing on odd word counts, fall back to the pre-v0.7.22 behavior (treat the entire string as a single arg). The key-value pair splitting is preserved for even word counts.
Testing
SystemExit: 1without fixtest_odd_words_no_semicolons_exitstest that asserted the crash was correct behaviortest_config.pysuite — all deprecated MT config tests and explicit workers tests pass