Skip to content

fix: key builder encoding, reset_settings, and cache_evict guard - #30

Open
emiliano-go wants to merge 3 commits into
redis:mainfrom
emiliano-go:fix/key-settings-management
Open

emiliano-go wants to merge 3 commits into
redis:mainfrom
emiliano-go:fix/key-settings-management

Conversation

@emiliano-go

Copy link
Copy Markdown
Contributor

Changes

Bug: Key builder ambiguity with special characters in query values

default_key_builder used : as the key segment delimiter and joined query
params with :. Values containing :, =, or & created ambiguous keys
that could not round-trip correctly.

Fix: Changed the query-params segment to use & as a separator and
URL-encode values (%3A for :, %26 for &, %3D for =).

Bug: Missing reset_settings() for testing

get_settings() uses @lru_cache, caching the RedisSettings instance
forever. Tests that mutate environment variables cannot force a fresh reload.

Fix: Added reset_settings() that calls get_settings.cache_clear().
Exported from the public API.

Bug: cache_evict() with no args wipes ALL cache keys

Calling cache_evict() without eviction_group and without key_builder
silently deleted every key under the global prefix.

Fix: Added an early ValueError when both arguments are absent. To
intentionally wipe all keys the caller must provide an explicit
eviction_group.

@tishun
tishun self-requested a review August 19, 2026 13:10
@tishun tishun added the needs-triage The team needs to go through the provided information and analyse it label Aug 19, 2026
- Add _validate_eviction_group() that rejects *, ?, [, ] and unbalanced
  { / } in eviction_group at decoration time (cache, cache_put, cache_evict)
- Prevents accidental full cache wipe via SCAN pattern injection
- Prevents broken Redis Cluster hash-slot routing from unbalanced braces
- Add 10 test cases covering rejection and acceptance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-triage The team needs to go through the provided information and analyse it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants