| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The constructor accepts ?user/?password but getRedis() never called auth(), so every operation against a password-protected Redis failed with NOAUTH. Authenticate right after connect, using the ACL array form [user, password] when a username is set and the plain password form otherwise (phpredis >= 5.3). An auth failure throws RedisException inside the existing connect retry loop, so misconfiguration fails loudly with bounded retries instead of silently retrying unauthenticated operations.
|
Thanks for contributing! This repository is a read-only mirror; development for this library happens in packages/queue in the utopia-php monorepo. Please open this pull request there instead. |
Sorry, something went wrong.
The shared Redis DSN carries _APP_REDIS_USER/_APP_REDIS_PASS and the cache/pubsub pools authenticate with them, but the publisher pool constructed its queue connection with host and port only, so every publish fails with NOAUTH on a password-protected Redis - and because the combined worker borrows the publisher pool for its consumer (worker.php), messages pile up as well. Pass $dsn->getUser() and $dsn->getPassword() through to Queue\Connection\Redis (both nullable; inert against current utopia-php/queue releases, live once utopia-php/queue#87 ships within the pinned ^2.0.0).
Greptile SummaryThe PR authenticates Redis connections immediately after connecting when credentials are configured.
Confidence Score: 4/5The PR is not yet safe to merge because valid "0" password or username configurations remain unable to authenticate. The authentication path correctly covers ordinary credentials, but PHP’s empty() semantics leave a concrete valid-credential case broken and make the intended fix incomplete. Files Needing Attention: src/Queue/Connection/Redis.php Important Files Changed
### Issue 1
src/Queue/Connection/Redis.php:205-208
**Valid credentials treated as absent**
A password equal to the valid string `"0"` is treated as absent because PHP considers `"0"` empty. This skips `auth()`, so operations against a protected Redis instance still fail with `NOAUTH`. An ACL username of `"0"` is also misclassified, causing password-only authentication instead of ACL authentication.
```suggestion
if ($this->password !== null) {
// ACL form when a username is configured, plain password otherwise.
$redis->auth($this->user !== null ? [$this->user, $this->password] : $this->password);
}
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix(redis): authenticate connection when..." | Re-trigger Greptile |
Sorry, something went wrong.
| if (!empty($this->password)) { | ||
| // ACL form when a username is configured, plain password otherwise. | ||
| $redis->auth(!empty($this->user) ? [$this->user, $this->password] : $this->password); | ||
| } |
There was a problem hiding this comment.
Valid credentials treated as absent
A password equal to the valid string "0" is treated as absent because PHP considers "0" empty. This skips auth(), so operations against a protected Redis instance still fail with NOAUTH. An ACL username of "0" is also misclassified, causing password-only authentication instead of ACL authentication.
| if (!empty($this->password)) { | |
| // ACL form when a username is configured, plain password otherwise. | |
| $redis->auth(!empty($this->user) ? [$this->user, $this->password] : $this->password); | |
| } | |
| if ($this->password !== null) { | |
| // ACL form when a username is configured, plain password otherwise. | |
| $redis->auth($this->user !== null ? [$this->user, $this->password] : $this->password); | |
| } |
This is a comment left during a code review.
Path: src/Queue/Connection/Redis.php
Line: 205-208
Comment:
**Valid credentials treated as absent**
A password equal to the valid string `"0"` is treated as absent because PHP considers `"0"` empty. This skips `auth()`, so operations against a protected Redis instance still fail with `NOAUTH`. An ACL username of `"0"` is also misclassified, causing password-only authentication instead of ACL authentication.
```suggestion
if ($this->password !== null) {
// ACL form when a username is configured, plain password otherwise.
$redis->auth($this->user !== null ? [$this->user, $this->password] : $this->password);
}
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
The Connection\Redis constructor has accepted ?user/?password since 2.0.x, but getRedis() never calls auth() - the credentials are stored and ignored. Against a password-protected Redis (requirepass or ACL), every publish/consume fails with NOAUTH.
Concrete downstream symptom: appwrite/appwrite#13554 - Appwrite's queue publisher pool passes host+port only, and even with credentials threaded through, this connection never authenticates. Cache/pubsub pools in the same app authenticate fine, so the failure is isolated to the queue workers.
Fix
getRedis() calls $redis->auth() immediately after connect() when a password is set:
Prior art
#29 attempted this in January (thanks @kodejuice for the first pass) but stalled with no description and predates the constructor credentials entirely; this PR revives the approach against current main, covering the ACL username form and the retry-loop failure semantics.
Verification
Constructor signature, the getRedis() connect/retry structure, and phpredis auth() forms all confirmed in source at main (7d8612c). Not run: no PHP runtime or live Redis in the author's environment - external red proof is the reporter's hourly NOAUTH log on appwrite/appwrite#13554 with every sibling pool authenticating.