chore(error messages): clarify reasons for refusing values#237
chore(error messages): clarify reasons for refusing values#237jelmerdemaat wants to merge 1 commit intojshttp:masterfrom
Conversation
|
I'm sorry, re-opening for proper review, I closed it accidentally purging Dependabot updates. |
|
@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? |
|
@blakeembrey would you still like this PR to be merged? :) |
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}.`); |
There was a problem hiding this comment.
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.
I was working with this package via
@nestjs/platform-expressand 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 thecookieNameRegExpcheck was rejecting my cookie name. This cookie name was valid before:test::nameThis 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 invalidmakes it seem like the argument variable name itself is invalid. I would suggest improving the error texts like so:I have improved this in all error messages in the
index.tsfile.