Hi :slightly_smiling_face: I wanted to share with...
# pact-broker
r
Hi 🙂 I wanted to share with you what I'm seeing in my Pact Broker, and see if anyone can help me understand what's happening. We have set our Pact Broker image and our Webhook (reacting to the
contract_content_changed
event), and I was working on a consumer & provider sample repos. What is happening right now is that once the contract changes, the Webhook gets executed and makes a request to our internal CI tool, which runs the provider verification. Once that happens, the provider contract tests pass and the verification result is published. The issue I have is that, even the verification passed and the UI shows it
green
, we still see
red
on the Webhook status column (screenshot attached). If I go in to try to see what happened, I see that shows two webhook executions: one from a few days ago (that failed) and one from today (that succeeded). I have also attached an screenshot showing it. To me it looks like somehow it keeps showing an earlier webhook execution that failed, and I can't get "rid of it". Could you help me understand what's happening?
This screenshot may be useful too:
b
See if you can delete the failing triggered webhook through the HAL browser
r
How could I do that? The thing is that when I try to see the webhooks cerated in the Broker, I only see 1:
b
there’s 1 webhook, it’s been triggered multiple times for different events.
go to the webhook, and see if you can navigate to the triggered webhooks for that webhook.
👍 1
just checked. there’s no hal relation for it, but you can just put “/triggered-webhooks” on the end of the webhook URL.
oooh, actually, that’s a Pactflow only route. it’s not in the OSS code.
r
if you mean
...../webhooks/{webhookId}/triggered-webhooks
, I get a 404
oh, that makes sense then 😅
b
yeah, sorry
r
should I remove the webhook and try to create it again?
b
it’s probably easiest 😆
the reason you’ve got a failure there is that it groups the triggered webhooks by the event type
so you’ve probably got multiple event types that have triggered it, and it failed for the most recent triggering of one event type, but not the other.
r
but if you check the screenshoot in my main message, the event that triggered both was the same as far as I can see
b
in the HAL browser, on the webhook status resource, you should have a link of triggered webhooks in the resources section
message has been deleted
you could see if one of htem was failed and delete that, but then the triggered webhook from before that would be used in the calculation, and if that one is failed, then it won’t help!
so, probably best to clear it all out and start again
r
What I don't understand is why I got that first execution (
triggeredWebhooks[0]
) that doesn't look like my created webhook... I guess I created a "bad" webhook at some point, and I'm paying the prize now 😅 😆
I will try to clean them and start again, and see if that solves this 🙂
b
working out how to summarise all the webhook data into one status was tricky, and while I’m not convinced there’s a bug there, it might be showing data in an unexpected way.
r
Probably I messed something up while trying to create the webhook, I'm not sure there's a bug either. I was just trying to understand what could be going on, because I could mess it up again in a similar way in the future 😅
b
turn it off and on again 😆
😆 1
r
it hasn't worked 😅 I tried to remove the webhook using a DELETE to
..../webhooks/{id}
, and it looked like it was deleted looking at the Broker UI. But then I created it again (2 times, the fist one I created it wrong and then I did it well), and it showed all the previous data, and all the previous executions are still there. Hence, I can't get a "green" status in the Broker UI because it still takes into account executions with deleted webhooks
b
oh, I wonder if there’s some logic in there that was too smart for this sitaution.
r
Only the last one has been executed with the existing version of the webhook
b
now I think about it, I think that the triggered webhooks are kept around when the webhook is deleted to ensure that a status can be calculated. sigh.
dammit, past beth.
😆 1
do you have access to the database?
r
I guess so
b
you might need to clear the triggered webhooks table, if it’s important to you.
r
I was going to ask if there was any API endpoint to remove that data, or if I had to look at the DB directly
b
if you can’t identify the triggered webhook that’s failed, then you’ll need to go to the db.
is it not one of the ones listed in the embedded resources?
you just send a DELETE to it in the HAL browser.
r
DELETE to the triggered-webhook?
b
yes
r
let me try it
I'm getting
404
, I'm not sure I'm sending the DELETE request to the proper path. I'm trying to do this:
<http://my-broker/triggered-webhooks/fd6ecab9-bc36-4a06-a035-801bba7c6bd1>
That's what I get when navigating through the HAL Browser to get the status of the webhook executions for my applications. I mean, it points me to that path + /logs to check the execution logs:
<http://my-broker/pacts/provider/ms-common--pact-provider-sample/consumer/ms-common--pact-consumer-sample/webhooks/status>
b
looks right
should not 404. let me try.
r
maybe the fact that those webhooks have been deleted matters here?
b
huh. ok, i never made a triggered webhook endpoint.
only one for the logs.
you’ll need to clear the database table, sorry.
delete from triggered_webhooks
r
no worries, I'll try to do it and see it that does the trick 🙂
b
if it doesn’t, the only other way is to delete the whole database 💥
jk
r
so, one final question. As far as I understand, once a webhook execution fails, we will have a "red" state in the broker UI until we have a newer one that succeeds. But if we at some point need to create a new version of the webhook, we will face this same issue if we had the previous version's last execution state as not-successful (either failed or retrying)
I mean the last execution for any given contract
b
hm, you make a good point.
I think I need to update the logic for the webhook status so it only takes into consideration the current webhooks
you can raise an issue in the pact-broker repository describing the problem if you like.
r
sounds good to me, but I don't know what side-effects that may have 😅 And yeah, I will create an issue there 🙂 Thank you very much for all the help!
I have opened this issue: https://github.com/pact-foundation/pact_broker/issues/568 Please, let me know if you want me to add any further information that might be useful 🙂
👍🏼 1