Skip to content

fix: allow rediss:// TLS endpoint with separately-configured password#2099

Merged
Ullaakut merged 2 commits intogomods:mainfrom
jalee-cpu:fix-redis-tls-password-mismatch
Apr 5, 2026
Merged

fix: allow rediss:// TLS endpoint with separately-configured password#2099
Ullaakut merged 2 commits intogomods:mainfrom
jalee-cpu:fix-redis-tls-password-mismatch

Conversation

@jalee-cpu
Copy link
Copy Markdown
Contributor

Problem

When using a TLS Redis endpoint (rediss://host:6379) without an embedded password, redis.ParseURL succeeds but returns options.Password = "". The current check in getRedisClientOptions then fires errPasswordsDoNotMatch if ATHENS_REDIS_PASSWORD is also set — even though there is no actual conflict, the URL simply has no password component.

// Current (broken for rediss:// + separate password)
if password != "" && options.Password != password {
    return nil, errPasswordsDoNotMatch  // "" != "realpassword" → crash
}

This makes it impossible to use the common Kubernetes deployment pattern of:

  • ATHENS_REDIS_ENDPOINT=rediss://host:6379 (TLS scheme, no password embedded in URL)
  • ATHENS_REDIS_PASSWORD=<secret> (injected separately via a k8s Secret)

ElastiCache and other managed Redis services commonly require both TLS (rediss://) and an auth token, and best practice is to inject credentials via secrets rather than embedding them in the endpoint URL.

Fix

Only error when the URL contains a password that disagrees with the separately-configured password. When the URL has no embedded password but ATHENS_REDIS_PASSWORD is set, apply the password to options so it is used for AUTH.

// Fixed
if options.Password != "" && password != "" && options.Password != password {
    return nil, errPasswordsDoNotMatch
}
if options.Password == "" && password != "" {
    options.Password = password
}

Test

Added a test case for rediss://host:6379 + separate password to Test_getRedisClientOptions. All existing tests continue to pass.

When using a TLS endpoint (rediss://host:6379) without an embedded
password, redis.ParseURL succeeds but sets options.Password to "".
The existing check then fires errPasswordsDoNotMatch if
ATHENS_REDIS_PASSWORD is set, even though there is no actual conflict —
the URL simply has no password component.

Fix the check so it only errors when the URL contains a password that
disagrees with the separately-configured password. When the URL has no
embedded password but ATHENS_REDIS_PASSWORD is set, apply the password
to options so it is actually used for AUTH.

This enables the common deployment pattern of:
  ATHENS_REDIS_ENDPOINT=rediss://host:6379   (TLS, no password in URL)
  ATHENS_REDIS_PASSWORD=<secret>             (injected via k8s Secret)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@Ullaakut Ullaakut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Ullaakut Ullaakut added the bug Something isn't working label Apr 3, 2026
@jalee-cpu
Copy link
Copy Markdown
Contributor Author

jalee-cpu commented Apr 3, 2026

LGTM

Thank you for the approval! What are the steps to merge?

@Ullaakut Ullaakut merged commit b56bb3b into gomods:main Apr 5, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants