Skip to content

fix(ui): accept IPv6 hosts in connection URLs - #6555

Open
RaphaelFakhri wants to merge 2 commits into
redis:mainfrom
RaphaelFakhri:fe/bugfix/connection-url-ipv6-host
Open

RaphaelFakhri wants to merge 2 commits into
redis:mainfrom
RaphaelFakhri:fe/bugfix/connection-url-ipv6-host

Conversation

@RaphaelFakhri

@RaphaelFakhri RaphaelFakhri commented Oct 21, 2026 •

Copy link
Copy Markdown

What

Fixes #6554.

parseRedisUrl matches the host part of a connection URL with [^:\/]+, so a bracketed IPv6 host such as redis://[::1]:6379 never matches and the function returns null. The Connection URL field on the add database screen then reports the URL as invalid, pasting the URL into the manual form does not fill in host and port, and a redisUrl passed through the redisinsight:// deep link is ignored.

This change lets the host be either a bracketed IPv6 address or the existing hostname pattern, in both the redis[s]:// form and the bare host:port form. The brackets are removed from host, so the API receives ::1, which is what the manual form already accepts for IPv6. hostname, which is used as the default database alias, keeps the brackets ([::1]:6379) so the port stays readable. Hostnames, IPv4 addresses, and credentials that contain @ or : are parsed as before.

Testing

Added three cases to redisinsight/ui/src/utils/tests/parseRedisUrl.spec.ts: [::1]:6379, redis://[::1], and rediss://user:pa@ss@[2001:db8::1]:6380/2.

npx jest -w 1 redisinsight/ui/src/utils/tests/parseRedisUrl.spec.ts
  • Before the fix: the three new cases fail because parseRedisUrl returns null (3 failed, 17 passed).
  • After the fix: 20 passed.

The add database screen, global URL handler, and home form utility specs also pass (5 suites, 39 tests). ESLint and Prettier pass on both changed files.


Note

Low Risk
Localized URL parsing change with added tests; no auth, persistence, or API contract changes beyond accepting previously failing IPv6 inputs.

Overview
Fixes IPv6 Redis connection URLs being rejected as invalid by extending parseRedisUrl to recognize bracketed IPv6 hosts in both bare host:port strings and full redis[s]:// URLs.

The parser now matches \[[^\]]+\] alongside the existing hostname pattern, then strips square brackets from the captured host so downstream connection logic receives addresses like ::1 (aligned with the manual form). hostname (default database alias) is built from the unwrapped host plus optional port, e.g. ::1:6379.

Three unit tests cover [::1]:6379, redis://[::1], and a credentialed rediss:// URL with [2001:db8::1]:6380/2. IPv4, DNS names, and passwords containing @ or : are unchanged.

Reviewed by Cursor Bugbot for commit 449eae6. Bugbot is set up for automated code reviews on this repo. Configure here.

@RaphaelFakhri
RaphaelFakhri requested a review from a team as a code owner October 21, 2026 07:13
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T12:37:01.959688Z 449eae6 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@CLAassistant

CLAassistant commented Oct 21, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a41155a23

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 57 to 59
host: unwrapIpv6Host(host),
port: port ? parseInt(port, 10) : undefined,
hostname: port ? `${host}:${port}` : host,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve default-name syncing for IPv6 aliases

When an explicitly ported URL such as redis://[::1]:6379 is saved, these lines produce host = "::1" but name = "[::1]:6379". On a later edit that changes only the host or port, DatabaseService.hasDefaultEndpointName in redisinsight/api/src/modules/database/database.service.ts:119-120 compares that generated name with ${database.host}:${database.port} (::1:6379), classifies it as a custom alias, and therefore skips the synchronization at lines 297-302, leaving the old endpoint displayed as the database name. Use the same IPv6-aware endpoint formatter for both generated aliases and default-name detection/synchronization.

Useful? React with 👍 / 👎.

@RaphaelFakhri

Copy link
Copy Markdown
Author

Good catch. The generated name for an IPv6 URL is now host:port without brackets (for example ::1:6379), the same format the API uses for default names. That keeps the name in sync when you later edit only the host or port. The parser tests cover it.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 449eae6580

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

port: port ? parseInt(port, 10) : undefined,
hostname: port ? `${host}:${port}` : host,
// same "host:port" format the API uses for default database names
hostname: port ? `${unwrappedHost}:${port}` : unwrappedHost,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include the effective port in generated IPv6 aliases

When the newly accepted no-port form redis://[::1] is used, this branch returns hostname: '::1'; AddDatabaseScreen.getPayload then assigns port 6379 (AddDatabaseScreen.tsx:44-46) while preserving that generated name. Since DatabaseService.hasDefaultEndpointName only recognizes ${host}:${port} (database.service.ts:119-120), changing the host or port later treats ::1 as a custom alias and leaves it stale. The earlier explicit-port mismatch is fixed by unwrapping, but the new no-port test at parseRedisUrl.spec.ts:174 shows this path remains; construct the alias with the effective port.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Without a port, main already uses the bare host as the name for every host, so redis://localhost gives localhost the same way redis://[::1] now gives ::1. This PR keeps that behavior. Adding the default port to no-port names would change it for IPv4 hosts and hostnames too, so it belongs in a separate change.

This branch has not been deployed

No deployments
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.

[Bug]: Connection URL with an IPv6 host is rejected as invalid

2 participants