Skip to content

fix(client): parse unix socket urls#3280

Open
raashish1601 wants to merge 1 commit into
redis:masterfrom
raashish1601:codex/2530-unix-socket-url
Open

fix(client): parse unix socket urls#3280
raashish1601 wants to merge 1 commit into
redis:masterfrom
raashish1601:codex/2530-unix-socket-url

Conversation

@raashish1601
Copy link
Copy Markdown
Contributor

@raashish1601 raashish1601 commented May 17, 2026

Summary

Adds unix:// URL parsing to RedisClient.parseURL, mapping the socket path into socket.path so callers can configure Unix domain socket connections through the same url option as TCP/TLS connections.

Supported forms include:

  • unix:///tmp/redis.sock?db=2
  • unix://user:secret@/tmp/redis.sock?db=3

The 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.ts because npm run lint:changed lints the whole touched file and current master has pre-existing lint violations in that file.

Closes #2530.

Validation

  • direct node -r ts-node/register/transpile-only checks for Unix socket path, db, credentials provider, and invalid authority
  • npm run lint:changed
  • npm run build
  • git diff --check

I 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 at spawn docker ENOENT because 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 to RedisClient.parseURL, allowing Unix domain socket connections via url by mapping the decoded socket path into socket.path and parsing db from the query string.

Refactors credential extraction into a shared helper so both TCP/TLS and Unix URLs produce username/password plus the async credentialsProvider, and adds validation for malformed Unix authority/path/database values.

Includes small TypeScript typing/lint cleanups around the client factory/proxy types, Multi construction, 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.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit bbdc01b. Configure here.

}

parsed.database = parsedDatabase;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bbdc01b. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Have parseUrl handle unix domain sockets

1 participant