Skip to content

fix(router): remove orphaned :route_config key on SemanticRouter.delete() (#634)#637

Closed
ngochuyinfo-crypto wants to merge 1 commit into
redis:mainfrom
ngochuyinfo-crypto:fix/router-delete-orphan-config
Closed

fix(router): remove orphaned :route_config key on SemanticRouter.delete() (#634)#637
ngochuyinfo-crypto wants to merge 1 commit into
redis:mainfrom
ngochuyinfo-crypto:fix/router-delete-orphan-config

Conversation

@ngochuyinfo-crypto

@ngochuyinfo-crypto ngochuyinfo-crypto commented Jun 23, 2026

Copy link
Copy Markdown

Fixes #634.

Problem

SemanticRouter persists config at {name}:route_config but delete() only dropped the search index, leaving that JSON key orphaned. A later from_existing(name) could read stale config from a deleted router.

Fix

delete() now also removes the {name}:route_config key.

Tests

  • Add test_delete_removes_route_config_key: asserts config key is gone after delete() and from_existing() raises instead of reading stale config.
  • Wrap fixed-name routers in test_key_separator_handling.py in try/finally so they clean up their index + config key.

Verification

4 passed in 138.97s

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_config JSON key in addition to dropping the search index, so deleted routers do not leave stale config that from_existing() could still load.

A new integration test checks the config key is absent after delete() and that from_existing() fails on that name. Key-separator integration tests that create fixed-name routers now use try/finally with router.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.

…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
@jit-ci

jit-ci Bot commented Jun 23, 2026

Copy link
Copy Markdown

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.

@vishal-bala

Copy link
Copy Markdown
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)

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.

SemanticRouter.delete() leaves orphaned {name}:route_config key in Redis

2 participants