Skip to content

MOD-14486: Fix crash on odd word count in space-separated moduleArgs#244

Open
ofiryanai wants to merge 2 commits intoRedisLabsModules:masterfrom
ofiryanai:MOD-14486-fix-odd-words-crash
Open

MOD-14486: Fix crash on odd word count in space-separated moduleArgs#244
ofiryanai wants to merge 2 commits intoRedisLabsModules:masterfrom
ofiryanai:MOD-14486-fix-odd-words-crash

Conversation

@ofiryanai
Copy link
Copy Markdown

@ofiryanai ofiryanai commented Apr 5, 2026

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:

WORKERS 0; TIMEOUT 0; DEFAULT_DIALECT 2

A per-test Env() call uses space-separated args without semicolons:

Env(moduleArgs='FORK_GC_CLEAN_NUMERIC_EMPTY_NODES _FORK_GC_CLEAN_NUMERIC_EMPTY_NODES true')

When fix_modulesArgs processes the per-test string, it sees no semicolons and enters the new code path from PR #243. It counts words:

  1. FORK_GC_CLEAN_NUMERIC_EMPTY_NODES (module name/prefix)
  2. _FORK_GC_CLEAN_NUMERIC_EMPTY_NODES (config key)
  3. 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 VALUE pairs 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

  • Added 3 new tests for odd word counts (1, 3, and 5 words) — all pass with fix, all crash with SystemExit: 1 without fix
  • Replaced the old test_odd_words_no_semicolons_exits test that asserted the crash was correct behavior
  • Tested locally with RediSearch's test_config.py suite — all deprecated MT config tests and explicit workers tests pass

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.
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.

1 participant