fix(client): parse unix socket urls#3280
Open
raashish1601 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit bbdc01b. Configure here.
| } | ||
|
|
||
| parsed.database = parsedDatabase; | ||
| } |
There was a problem hiding this comment.
Empty db query parameter silently maps to database 0
Low Severity
When the db query parameter is present but empty (e.g., unix:///tmp/redis.sock?db= or unix:///tmp/redis.sock?db), searchParams.get('db') returns '', which passes the !== null check. Number('') evaluates to 0 and isNaN(0) is false, so parsed.database is silently set to 0. Given the PR explicitly validates malformed database values (e.g., ?db=NaN), an empty value likely qualifies as malformed and probably warrants a similar TypeError rather than a silent default.
Reviewed by Cursor Bugbot for commit bbdc01b. Configure here.
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.


Summary
Adds
unix://URL parsing toRedisClient.parseURL, mapping the socket path intosocket.pathso callers can configure Unix domain socket connections through the sameurloption as TCP/TLS connections.Supported forms include:
unix:///tmp/redis.sock?db=2unix://user:secret@/tmp/redis.sock?db=3The parser also preserves the existing async credentials provider behavior for URL credentials and validates malformed Unix socket authority/database values.
This PR also includes small typed cleanups in
client/index.tsbecausenpm run lint:changedlints the whole touched file and current master has pre-existing lint violations in that file.Closes #2530.
Validation
node -r ts-node/register/transpile-onlychecks for Unix socket path, db, credentials provider, and invalid authoritynpm run lint:changednpm run buildgit diff --checkI also attempted
npx mocha --require ts-node/register/transpile-only packages/client/lib/client/index.spec.ts --grep unix://, but this repo starts its Docker-backed Redis test environment in global hooks before grep-selected tests run. It failed locally atspawn docker ENOENTbecause Docker is not installed in this environment.Note
Medium Risk
Moderate risk because it changes URL parsing and client option derivation, which can affect connection/auth configuration across callers; coverage is improved with new unit tests for unix URLs and invalid inputs.
Overview
Adds
unix://URL support toRedisClient.parseURL, allowing Unix domain socket connections viaurlby mapping the decoded socket path intosocket.pathand parsingdbfrom the query string.Refactors credential extraction into a shared helper so both TCP/TLS and Unix URLs produce
username/passwordplus the asynccredentialsProvider, and adds validation for malformed Unix authority/path/database values.Includes small TypeScript typing/lint cleanups around the client factory/proxy types,
Multiconstruction, and invalidate push handler typing.Reviewed by Cursor Bugbot for commit bbdc01b. Bugbot is set up for automated code reviews on this repo. Configure here.