Skip to content

feat(client): improve client instantiation error messages - #3441

Merged
nkaradzhov merged 2 commits into
redis:masterfrom
AniaMakes:feat-improve-client-instantiation-error-messages
Sep 13, 2026
Merged

nkaradzhov merged 2 commits into
redis:masterfrom
AniaMakes:feat-improve-client-instantiation-error-messages

Conversation

@AniaMakes

@AniaMakes AniaMakes commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

We are using this module and have found that the errors could be a bit better.

This PR adds a check that the URL is actually a url, and improves the TypeError - invalid protocol - to include the protocol that it does see.

Please note that upon npm i and then npm t the tests fail to run with a number of MODULE_NOT_FOUND messages. The npm run build:tests-tools && npm test listed in the Contributing guide result in Missing script: "build:tests-tools". Hopefully this PR is small enough to easily pass tests running on CI etc.

Thank you in advance

Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?

Note

Low Risk
String-only change to a validation error path in URL parsing; no connection or auth behavior changes.

Overview
When createClient (or parseURL) is given a connection URL whose scheme is not redis: or rediss:, the client now throws a TypeError that includes the actual protocol from the URL and states that redis: or rediss: are expected.

Previously the message was the generic Invalid protocol, which made mis-typed schemes (e.g. redi://) harder to diagnose at instantiation time.

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

@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: 910f288483

ℹ️ 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 thread packages/client/lib/client/index.ts Resolved
Comment thread packages/client/lib/client/index.ts Resolved

@cursor cursor 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.

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

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 910f288. Configure here.

Comment thread packages/client/lib/client/index.ts Resolved

@nkaradzhov nkaradzhov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @AniaMakes — we'd like to keep the improved protocol error, but please drop the URL.canParse guard: it breaks supported unix://user:pass@/sock URLs, duplicates the TypeError that new URL already throws, and can leak passwords into error messages. The new test also passes on master, so remove or repurpose it. Your CONTRIBUTING.md complaint is valid; we'll fix that separately.

@AniaMakes

Copy link
Copy Markdown
Contributor Author

@nkaradzhov thank you for 👀 , done. Please let me know if you'd rather I cleaned up the commits so that there's only one.

@nkaradzhov nkaradzhov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @AniaMakes this looks good. We will squash it on merge :)

@AniaMakes

Copy link
Copy Markdown
Contributor Author

@nkaradzhov Thank you, I'll leave you (or one of your colleagues) to merge as convenient; I don't appear to have the rights to do so.

@nkaradzhov
nkaradzhov merged commit 690768b into redis:master Sep 13, 2026
15 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.

2 participants