-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update error msg on stale request #1503
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1503 +/- ##
==========================================
+ Coverage 81.99% 82.00% +0.01%
==========================================
Files 18 18
Lines 1494 1495 +1
Branches 435 435
==========================================
+ Hits 1225 1226 +1
Misses 172 172
Partials 97 97
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A minor suggestion. What do you think?
src/receivers/verify-request.ts
Outdated
@@ -44,7 +44,7 @@ export function verifySlackRequest(options: SlackRequestVerificationOptions): vo | |||
|
|||
// Rule 1: Check staleness | |||
if (requestTimestampSec < fiveMinutesAgoSec) { | |||
throw new Error(`${verifyErrorPrefix}: stale`); | |||
throw new Error(`${verifyErrorPrefix}: x-slack-request-timestamp must differ from system time by no more than 5 minutes or request is stale`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you replace the hard-coded "5" in the log message? Perhaps, we can add a new local variable for the minutes above in this method and embed the value in the log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, can you check this?
Co-authored-by: Kazuhiro Sera <[email protected]>
@seratch - Oh yes, that's definitely better. I was going too fast! Just checked it's fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't checked wether this works on my local machine but if it works, looks great to me 👍
@seratch - If you mean testing how a template literal would handle injecting the number, yes it looks like no complaints - tests are passing as well. |
Summary
Fix #1502.
Tweaks error messages in case of stale request to add more detail for end-users
Requirements (place an
x
in each[ ]
)