fix(router): remove orphaned :route_config key on SemanticRouter.delete() (#634)#637
Closed
ngochuyinfo-crypto wants to merge 1 commit into
Closed
Conversation
…te()
SemanticRouter persists its config at `{name}:route_config` on init and on
route mutations, but `delete()` only dropped the search index and left that
JSON key stranded in Redis. A later `from_existing(name)` could then read
stale config from a router that was supposedly deleted.
`delete()` now also removes the `{name}:route_config` key so deletion fully
removes router state.
Tests:
- Add `test_delete_removes_route_config_key` asserting the config key is gone
after `delete()` and that `from_existing()` raises instead of reading stale
config.
- Wrap the fixed-name routers in `test_key_separator_handling.py`
(`test_router_sep`, `router_sep_test`, `router_trailing_test`) in
try/finally so they clean up their index and config key after the test.
Fixes redis#634
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
Collaborator
|
Thanks for your contribution, but we already have a PR in-flight for this issue: #635 (Seems like this is a bot in any case) |
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.
Fixes #634.
Problem
SemanticRouterpersists config at{name}:route_configbutdelete()only dropped the search index, leaving that JSON key orphaned. A laterfrom_existing(name)could read stale config from a deleted router.Fix
delete()now also removes the{name}:route_configkey.Tests
test_delete_removes_route_config_key: asserts config key is gone afterdelete()andfrom_existing()raises instead of reading stale config.test_key_separator_handling.pyin try/finally so they clean up their index + config key.Verification
Ran against redis:8.4 (Search + JSON) with the real HF vectorizer.
Note
Low Risk
Small, targeted lifecycle fix in router teardown plus test cleanup; no auth or core routing logic changes.
Overview
SemanticRouter.delete()now removes the persisted{name}:route_configJSON key in addition to dropping the search index, so deleted routers do not leave stale config thatfrom_existing()could still load.A new integration test checks the config key is absent after
delete()and thatfrom_existing()fails on that name. Key-separator integration tests that create fixed-name routers now usetry/finallywithrouter.delete()so index and config are cleaned up.Reviewed by Cursor Bugbot for commit ce14afe. Bugbot is set up for automated code reviews on this repo. Configure here.