Skip to content

fix(cli): make module_list check robust to bytes/str key types#67

Open
gkorland wants to merge 1 commit into
masterfrom
fix/module-list-keytype
Open

fix(cli): make module_list check robust to bytes/str key types#67
gkorland wants to merge 1 commit into
masterfrom
fix/module-list-keytype

Conversation

@gkorland

Copy link
Copy Markdown

Summary

The two CLIs disagreed on the key type used to look up module names returned by Redis:

  • bulk_insert.py used m[b"name"] and b"graph" not in module_list.
  • bulk_update.py used m["name"] and "graph" not in module_list.

Whether the key comes back as bytes or str depends on the underlying redis-py client's decode_responses setting, which is not guaranteed to stay consistent across redis-py / falkordb-py versions. If the configuration changed, one of the two CLIs would silently stop detecting the module and either crash with a KeyError or always print "module not loaded".

Changes

  • Both CLIs now look up the name with either key type (m.get(b"name", m.get("name"))) and decode bytes to str before comparing against "graph".

Testing

Lint clean (flake8, black).

Memory / Performance Impact

N/A.

Related Issues

From the comprehensive code-review report (BUG-14).

@coderabbitai

coderabbitai Bot commented Apr 26, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@gkorland has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 23 minutes and 7 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1465d31c-0eef-4100-877e-cc117c47448f

📥 Commits

Reviewing files that changed from the base of the PR and between 3954856 and c68dcd4.

📒 Files selected for processing (2)
  • falkordb_bulk_loader/bulk_insert.py
  • falkordb_bulk_loader/bulk_update.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/module-list-keytype

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 23 minutes and 7 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Apr 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.35%. Comparing base (3954856) to head (c68dcd4).

Files with missing lines Patch % Lines
falkordb_bulk_loader/bulk_insert.py 83.33% 1 Missing ⚠️
falkordb_bulk_loader/bulk_update.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #67      +/-   ##
==========================================
- Coverage   89.50%   89.35%   -0.16%     
==========================================
  Files           9        9              
  Lines         610      620      +10     
==========================================
+ Hits          546      554       +8     
- Misses         64       66       +2     

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

@gkorland
gkorland marked this pull request as ready for review April 26, 2026 17:57
@gkorland

Copy link
Copy Markdown
Author

Copilot Code Review

⚠️ Medium-severity issue found: Permissive UTF-8 decoding

Files: falkordb_bulk_loader/bulk_insert.py:207 and falkordb_bulk_loader/bulk_update.py:203

Both use errors="replace" when decoding module names, which silently replaces invalid UTF-8 with the Unicode replacement character (U+FFFD). This masks encoding errors instead of making them explicit.

Fix: Use errors="strict" (the default) to raise UnicodeDecodeError on invalid UTF-8, or wrap in try/except with a clear error message.

@gkorland

Copy link
Copy Markdown
Author

Agent Review Summary

Issue Addressed

Addressed the medium-severity review comment from @gkorland:

Both CLIs used errors="replace" when decoding module names, silently replacing invalid UTF-8 with U+FFFD. This masks encoding errors instead of making them explicit.

Fix Applied

Removed the errors="replace" kwarg from both bulk_insert.py:208 and bulk_update.py:205, reverting to the default errors="strict" behaviour. Invalid UTF-8 in a module name will now raise UnicodeDecodeError explicitly rather than quietly substituting a replacement character that could allow a garbled name to silently pass the "graph" not in module_list check.

Commit: 89b09be

CI Status

✅ All checks passed (CodeQL × 2, CodeRabbit, Codecov)

Pre-existing test note

The integration tests in test/ require a live FalkorDB server and fail in this environment — this is pre-existing and unrelated to the PR changes.

`bulk_insert` indexed each module entry with the bytes key `b"name"`,
while `bulk_update` used the str key `"name"`. The actual key type
depends on the underlying redis-py client's `decode_responses` setting,
so one of the two would silently fail to detect the FalkorDB module if
client configuration changed. Normalise both code paths to look up the
name with either key type and decode bytes to str before comparison.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@gkorland
gkorland force-pushed the fix/module-list-keytype branch from 89b09be to c68dcd4 Compare April 29, 2026 06:58
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