-
Notifications
You must be signed in to change notification settings - Fork 1
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
Support webhook urls with missing threadkey parameter #24
Support webhook urls with missing threadkey parameter #24
Conversation
…eter This parameter used to require a `{threadKey}` placeholder, which is sometimes forgotten. We now support Webhook URLs that do not include this placeholder, and strip the placeholder if it was present.
34836e6
to
a1037eb
Compare
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.
Awesome :)
Might be one for another PR, but you could add cargo test
to https://github.com/guardian/actions-prnouncer/blob/main/.github/workflows/main.yml ?
src/google.rs
Outdated
match result { | ||
Ok(url) => assert_eq!(url, String::from("https://example.com/ABCDEF?messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD&threadKey=1234")), | ||
Err(_) => assert!(false), | ||
} |
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.
match result { | |
Ok(url) => assert_eq!(url, String::from("https://example.com/ABCDEF?messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD&threadKey=1234")), | |
Err(_) => assert!(false), | |
} | |
assert_eq!(url, Ok(String::from("https://example.com/ABCDEF?messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD&threadKey=1234"))) |
Is it possible to assert on a result perhaps?
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.
That isn't possible (Result doesn't support equality checks), but Result::unwrap
will work well in tests.
We include a test step in the GHA workflow file, and unwrap the Results in test assertions to simplify the code.
I've addressed both of these points, thank you! |
We ran through testing this locally before merging 👍 |
NOTE: this includes the changes in the new-inline-threads PR
What does this change?
Allows teams to provide a
{threadKey}
placeholder if they want to, but also supports cases where this is not included.I am led to believe this sometimes casuses problems, when teams forget the parameter.
I'd suggest we officially deprecate the placeholder parameter from here, so that there is a single recommended approach. There's no reference to this placeholder in the README or elsewhere, so I've not made any documentation changes.
How to test
I've added tests for this logic, but we'll also need to make sure that the existing behaviour still works. I do not have the secrets for testing at my fingertips, so if someone wants to pair with me on testing this locally I'd be grateful!
How can we measure success?
Existing configurations should continue to work unchanged, and we might consider updating the webhook URL for one or more of the existing configurations, removing the deprecated threadKey placholder.
Have we considered potential risks?
Testing this change locally would mitigate the risk of breaking existign configurations.