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

Webhooks V3 Support #367

Open
thde opened this issue Oct 5, 2021 · 8 comments
Open

Webhooks V3 Support #367

thde opened this issue Oct 5, 2021 · 8 comments
Assignees
Milestone

Comments

@thde
Copy link

thde commented Oct 5, 2021

As V1/V2 webhooks are being deprecated, are there plans to support V3 webhooks within go-pagerduty?

We wanted to let you know that Webhooks V3 is now live and available to everyone. Thank you for your continued feedback and support. Learn more about it "here":https://support.pagerduty.com/docs/webhooks.
This also means that Webhooks V1 and V2 are being deprecated on November 13, 2021 and March 31, 2022 respectively.

I've seen that #326 adds signature verification and should land in v1.5.0?
But the payload also seems to change between V2 and V3.

@theckman
Copy link
Collaborator

theckman commented Oct 7, 2021

If someone were to raise a PR, and be willing to address any feedback, that would probably be appreciated. I do not have the capability to merge my own PRs, but I can merge others, so I'm sort of reluctant to raise another PR that'll just sit for months...

Right now #326 is blocked pending requested changes, so it'll land in v1.5.0 if those are resolved.

@theckman
Copy link
Collaborator

From a comment I made here (#370 (comment)):

... based on the shape of the JSON documents for V3 Webhooks, I'm not confident we will be able to implement a single function to deserialize the response and provide a single useful data structure for the consumer to use.

V3 Webhooks do that thing where you need to have a two-phase deserialization, because the event.data field changes shape depending on the event.event_type. So I think they are ultimately going to have to do some of their own deserialization, most likely, with types we export. We could also offer functions for each type to make it easier in their code, since they'd just need to call webhookv3.ExtractIncident(json.RawMessage) or something.

That said, maybe we could accomplish it with something like this where there is a struct type with a method to access each potential payload data type. Consumers can use the EventType field of the Event struct, or they can hit each method until they get a valid event type:

type Payload struct {
	Event Event `json:"event"`
}

type Event struct {
	ID        string
	EventType EventType
	Data      Data
}

type EventType string

const (
	Incident     EventType = "incident"
	IncidentNote EventType = "incident_note"
)

type Data struct {
	eventType EventType
	// not sure what else yet...
}

// Incident returns the incident data from the payload. The bool return
// value will be true if data was incident data.
func (p Payload) Incident() (Incident, bool) {
	if p.eventType != Incident {
		return Incident{}, false
	}

	return // p.something...
}

func (p Payload) IncidentNote() (IncidentNote, bool) { }

@ChezCrawford
Copy link

Can't commit any sort of time frame but I am slowly working on this.

@theckman
Copy link
Collaborator

@ChezCrawford I've managed to get everything else for v1.5.0 ready go. Have you had the cycles to look at this at all? If not no sweat, and I'll retag it to be part of v1.6.0.

@ChezCrawford ChezCrawford modified the milestones: v1.5.0, v1.6.0 Jan 21, 2022
@ChezCrawford
Copy link

It's in the works but isn't quite ready for use. I'll shoot for something in v1.6.0.

@s-buhar0v
Copy link

s-buhar0v commented Feb 13, 2022

This also means that Webhooks V1 and V2 are being deprecated on November 13, 2021 and March 31, 2022 respectively.

Guys, any updates? @ChezCrawford

@theckman
Copy link
Collaborator

theckman commented Feb 13, 2022

So the one thing I am unsure of is how PagerDuty defines "deprecated". Whenever I've seen deprecated used elsewhere, it means things will keep working but it's either no longer the default option or it's no longer an option for new configurations.

If we assume the same is true for PD there isn't much of a risk for people who currently use Webhooks, but it could be slightly inconvenient for anyone trying to set up new ones.

Considering that, we should definitely get this into a release before the end of March. End of February might be more ideal date to aim for.

Edit: I have confirmed with PagerDuty that things will keep working when they are deprecated, but there will just be no support available:

The deprecation or End-of-Support for Webhooks v2 does not mean that integrations/extensions using Webhooks v2 will stop working. The deprecation of Webhooks v2 means that the Product and Support teams will officially stop providing support for issues related to v2, so no more bug fixes, new features, or support tickets for all things that use Webhooks v2.

@ChezCrawford
Copy link

Alright two threads here:

First, i've got a draft of some basic support for V3 Webhook Payloads in #427 and would appreciate and/all feedback.

Second: My apologies for the delay in communication regarding deprecation; this is has been a bit of a mess from our end. What @theckman said above is essentially correct. Furthermore: be on the lookout for some updated communication regarding webhook deprecation. We are going to do our best not to leave anyone out in the cold 😉 .

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

No branches or pull requests

5 participants