Skip to content

fix(query-redis-labs): support custom redis port and url - #495

Open
codax69 wants to merge 1 commit into
appwrite:mainfrom
codax69:fix/redis-port-config
Open

codax69 wants to merge 1 commit into
appwrite:mainfrom
codax69:fix/redis-port-config

Conversation

@codax69

@codax69 codax69 commented Nov 8, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes an issue in the node/query-redis-labs template where the Redis client was hardcoded to connect exclusively on port 14714. Redis Cloud assigns arbitrary ports to individual database instances, which previously prevented users from connecting unless their database was assigned port 14714.

Key Changes

  • Configurable REDIS_PORT: Added support for reading REDIS_PORT from environment variables, defaulting to the standard Redis port (6379) when not specified.
  • Support for host:port in REDIS_HOST: Automatically extracts the port if the user provides the host in hostname:port or bracketed IPv6 format ([::1]:port). Bare IPv6 addresses (e.g., ::1) are detected via node:net's isIP() and kept intact without misinterpreting the trailing segment as a port.
  • Connection URL Support (REDIS_URL): Added support for standard Redis connection URLs (redis://... / rediss://...).
  • Validation: Updated src/main.js so REDIS_HOST and REDIS_PASSWORD are only required when REDIS_URL is not provided.
  • Documentation: Updated README.md to document REDIS_PORT and REDIS_URL, clarifying that REDIS_HOST and REDIS_PASSWORD are required only when REDIS_URL is absent.

Test Plan

  1. Syntax and Linting:

    • Ran node --check across template JavaScript files.
    • Validated template build compatibility against repository CI steps.
  2. Configuration & Option Parsing Tests:

    • Verified that throwIfMissing correctly requires REDIS_HOST and REDIS_PASSWORD when REDIS_URL is absent.
    • Verified that supplying REDIS_URL allows execution without REDIS_HOST or REDIS_PASSWORD.
    • Verified client configuration for:
      • REDIS_URL
      • REDIS_HOST + REDIS_PASSWORD + explicit REDIS_PORT
      • REDIS_HOST containing host:port
      • Bare IPv6 addresses (::1) defaulting to port 6379
      • Bracketed IPv6 addresses with port ([::1]:8888)
    • Verified non-GET requests return standard 404 Not found.

Related PRs and Issues

  • Resolves issue: query-redis-labs can only connect to a Redis Cloud database that happens to use port 14714.
  • cc @adityaoberai

Have you read the Contributing Guidelines on issues?

Yes

@appwrite

appwrite Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The URL, host/port, and IPv6 handling is consistent with the Redis client configuration, and no behavior defect was found.

This change makes the Redis Labs template accept a connection URL or configure the host and port separately. It also parses ports embedded in host values, handles bare and bracketed IPv6 addresses, and documents the new environment variables.

Verdict New comments Fixed Still open
💬 Commented 0 0 0

Note

@codax69 does not have write access to this repository, so Hansi does not approve automatically. A maintainer can review and approve.

📂 Walkthrough · 3
File Change
node/query-redis-labs/README.md Documents REDIS_PORT and REDIS_URL and clarifies when host and password are required.
node/query-redis-labs/src/main.js Skips host/password validation when a Redis URL is configured.
node/query-redis-labs/src/redis.js Builds the Redis client from a URL or parsed host and port configuration.

Reviewed c482ee8 · Details · Comment @appwrite review to re-run, or mention @appwrite with a question.

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

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.

1 participant