Skip to content

Conversation

@jelmerdemaat
Copy link

I was working with this package via @nestjs/platform-express and I updated it from v0.5.0 to v0.7.1. After this my application login stopped working. I checked why this was, and ultimately I found out that the cookieNameRegExp check was rejecting my cookie name. This cookie name was valid before:

test::name

This wasn't valid anymore after updating. I don't know if this is correct, or if it is maybe already fixed in the most recent version of the package. That is not my issue.

What would have helped me find my issue sooner is a better error message. Looking at the existing text argument name is invalid makes it seem like the argument variable name itself is invalid. I would suggest improving the error texts like so:

Argument "name" is invalid: ${name}. It does not match the cookie name regular expression ${cookieNameRegExp}.

I have improved this in all error messages in the index.ts file.

@blakeembrey
Copy link
Member

I'm sorry, re-opening for proper review, I closed it accidentally purging Dependabot updates.

@blakeembrey blakeembrey reopened this Sep 22, 2025
@jelmerdemaat
Copy link
Author

@blakeembrey I see there are merge conflicts now, with what seem to be similar changes to mine. Should I update my code to re-match with master?

@jelmerdemaat
Copy link
Author

@blakeembrey would you still like this PR to be merged? :)

@blakeembrey
Copy link
Member

with what seem to be similar changes to mine

I'm not sure what this is referring to, sorry. But leaving some review comments now.


if (!cookieNameRegExp.test(name)) {
throw new TypeError(`argument name is invalid: ${name}`);
throw new TypeError(`Argument "name" is invalid: ${name}. It does not match the cookie name regular expression ${cookieNameRegExp}.`);
Copy link
Member

Choose a reason for hiding this comment

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

Let's try to minimally change the error message, otherwise this may break someone string matching. Something like:

argument name is invalid: ${name}, should match ${cookieNameRegExp}

Ditto for all the other errors too, if we can make it compact and keep the formatting/start of the error the same happy to land this in a patch/minor.

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