Skip to content
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

Merged
merged 3 commits into from
Jan 12, 2024

Conversation

adamnfish
Copy link
Contributor

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.

AshCorr and others added 2 commits January 12, 2024 11:44
…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.
@adamnfish adamnfish force-pushed the support-webhook-urls-with-missing-threadkey-parameter branch from 34836e6 to a1037eb Compare January 12, 2024 13:17
Copy link
Member

@AshCorr AshCorr left a 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
Comment on lines 65 to 68
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),
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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?

Copy link
Contributor Author

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.
@adamnfish
Copy link
Contributor Author

I've addressed both of these points, thank you!

@adamnfish adamnfish merged commit c51efad into main Jan 12, 2024
2 checks passed
@adamnfish adamnfish deleted the support-webhook-urls-with-missing-threadkey-parameter branch January 12, 2024 16:31
@adamnfish
Copy link
Contributor Author

We ran through testing this locally before merging 👍

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