Skip to content

fix: handle empty password, missing port, and TLS in Redis URL parsing - #2021

Merged
Philipinho merged 4 commits into
docmost:mainfrom
michidk-contrib:fix/redis-url-parsing
Aug 19, 2026
Merged

Philipinho merged 4 commits into
docmost:mainfrom
michidk-contrib:fix/redis-url-parsing

Conversation

@michidk

@michidk michidk commented Mar 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes three edge cases in parseRedisUrl() that cause issues with common Redis URL formats:

1. Empty password triggers ioredis warning

new URL('redis://localhost:6379').password returns "" (empty string). ioredis treats any string — including empty — as a supplied password, spamming logs with:

[WARN] This Redis server's default user does not require a password, but a password was supplied

Fix: password: password || undefined

2. Missing port produces NaN

new URL('redis://localhost/0').port returns "" when omitted. parseInt('', 10) is NaN, which breaks the connection.

Fix: port ? parseInt(port, 10) : 6379

3. rediss:// TLS silently dropped

For rediss:// URLs, the protocol indicates TLS should be used, but the parsed config object never included a tls field. Any code using the parsed config (instead of the raw URL string) silently drops TLS.

Fix: Extract protocol from the URL and return tls: {} for rediss:// schemes. Propagated to all Redis consumers (redis-config service, BullMQ queue module, collaboration gateway).

michidk added 2 commits March 15, 2026 14:33
- password: coerce empty string to undefined (suppresses ioredis warning)
- port: default to 6379 when omitted (prevents NaN from parseInt(''))
- tls: extract protocol and return tls: {} for rediss:// URLs
Pass tls config from parseRedisUrl to redis-config service, BullMQ queue, and collaboration gateway so rediss:// URLs actually enable TLS.
@CLAassistant

CLAassistant commented Mar 15, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@michidk michidk changed the title fix: harden Redis URL parsing (password, port, TLS) fix: handle empty password, missing port, and TLS in Redis URL parsing Mar 15, 2026
Yundi339 added a commit to Yundi339/docmost that referenced this pull request Apr 22, 2026
- parseRedisUrl now decodeURIComponent-s the password so URLs with
  percent-encoded specials (e.g. '%40' for '@') connect correctly.
- Missing port falls back to 6379 instead of NaN.
- rediss:// URLs now set tls: {} which is threaded through to the four
  ioredis consumers (collab, queue, nestjs-ioredis, throttler).

Cherry-picked from upstream docmost#1952 and docmost#2021.
@Philipinho
Philipinho merged commit 8c2c49e into docmost:main Aug 19, 2026
2 checks passed
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.

3 participants