fix: Redis password empty string treated as None#22
Open
sistemabritto wants to merge 1 commit into
Open
Conversation
When REDIS_PASSWORD is set to an empty string in docker-compose (common in community setups without Redis AUTH), os.getenv returns '' instead of None. redis-py sends AUTH even for empty string, causing Redis to reject with: AUTH <password> called without any password configured for the default user. Are you sure your configuration is correct? Fix in two places: 1. get_redis_config() now normalizes empty/whitespace-only password to None before returning the config dict. 2. MCPToolCache.__init__ adds a defensive check that also normalizes the password, in case get_redis_config is bypassed in the future.
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR ensures that an empty Redis password (common in Docker setups without authentication) is normalized to None both when reading configuration and when constructing the Redis client, preventing redis-py from sending an invalid AUTH command. Sequence diagram for Redis password normalization and client initializationsequenceDiagram
actor Env
participant get_redis_config
participant MCPToolCache
participant redis_client as redis_Redis
participant RedisServer
Env->>get_redis_config: os.getenv REDIS_PASSWORD
get_redis_config->>get_redis_config: normalize empty string to None
get_redis_config-->>MCPToolCache: redis_config(password=None)
MCPToolCache->>MCPToolCache: normalize empty password to None
MCPToolCache->>redis_client: Redis(host, port, db, password=None, ssl)
alt [password is None]
redis_client->>RedisServer: CONNECT without AUTH
else [password not None]
redis_client->>RedisServer: AUTH password
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The empty-string password normalization is implemented both in
get_redis_configandMCPToolCache.__init__; consider centralizing this logic in the config layer to avoid duplication and potential divergence. - If
redis_config['password']can only beNoneor a string, the extrastr(...)wrapping inMCPToolCache.__init__is unnecessary and could be simplified to keep the handling clearer.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The empty-string password normalization is implemented both in `get_redis_config` and `MCPToolCache.__init__`; consider centralizing this logic in the config layer to avoid duplication and potential divergence.
- If `redis_config['password']` can only be `None` or a string, the extra `str(...)` wrapping in `MCPToolCache.__init__` is unnecessary and could be simplified to keep the handling clearer.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Problema
Quando REDIS_PASSWORD esta vazio (comum em Docker Compose community sem senha), os.getenv retorna '' em vez de None. O redis-py envia AUTH com string vazia, que o Redis rejeita:
Fix
Co-Authored-By: sistemabritto admin@workflowapi.com.br
Summary by Sourcery
Bug Fixes: