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

Feature/add data to webhook #474

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

om-henners
Copy link
Contributor

Add the run data to the webhook message.

The gaol is that we should be able to use the data coming to the webhook to triage and send to other systems (alerting systems etc), and to do that it's useful to distinguish between the error messages that come through. So this adds that data in without modifying the existing data.

Happy to add tests as required.

@justb4
Copy link
Member

justb4 commented Aug 29, 2024

@om-henners also thanks here! Makes sense. Yes, please add tests. There are existing notification/webhook tests:
https://github.com/geopython/GeoHealthCheck/blob/master/tests/test_resources.py#L115.

@justb4
Copy link
Member

justb4 commented Aug 29, 2024

@tomkralidis you have time to review/maybe merge?

Henry Walshaw added 6 commits September 10, 2024 16:20
This does increase the message size, though I imagine that's marginal,
and is backwards compatible in that old keys remain in place and
aren't modified. The goal is to make the actual GHC app more set and
forget, and we can handle the errors with a little more discretion on
the webhook end.

The report is being sent as URLEncoded form data, which if we send a
hierarchy just sends a single key. We want the entire report so encode
the JSON as a string and send that. The keys are sorted to make
testing easier.
Python3 division is always float. Much easier to check if the code is
400 or more.
Also update the external links to be https (as otherwise we have to
wait for a bunch of redirects in the tests as well).
This uses the responses library to intercept the request so we can
confirm that the body content is exactly as expected.
Makes sure we're not accidentally doubling up somewhere
@om-henners
Copy link
Contributor Author

@justb4 added a simple test (sorry it took a little time to get to it my end). Happy to add more detail. But the most important thing I should note is that in doing so I introduced the https://github.com/getsentry/responses library as a testing lib to handle testing calling the webhook endpoint.

(I did try speeding things up for the testRunResources test using responses as well, but I couldn't get it working - lots of URL juggling with multiple redirects. Maybe a future cleanup PR!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants