go-playground / webhooks

:fishing_pole_and_fish: Webhook receiver for GitHub, Bitbucket, GitLab, Gogs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Payload Not Populating

kuiro5 opened this issue · comments

Seems to be similar #8. My payload does not seem to be populating properly. I'm using the PullRequestEvent, specifically the review_requested Action. I also noticed that the payload was missing the attribute requested_reviewers (https://developer.github.com/v3/activity/events/types/#pullrequestevent)

Hook

func main() {
	hook := github.New(&github.Config{Secret: os.Getenv("GITHUB_SECRET")})
	hook.RegisterEvents(HandlePullRequestEvent, github.PullRequestEvent)
	port := os.Getenv("PORT")

	err := webhooks.Run(hook, ":"+port, path)
	if err != nil {
		fmt.Println(err)
	}
}

Handling the Event

pullRequestPayload := payload.(github.PullRequestPayload)
fmt.Printf("%+v", pullRequestPayload)            // Seen below
fmt.Println(pullRequestPayload.Action)           // Empty

Payload

{Action: Number:0 PullRequest:{URL: ID:0 HTMLURL: DiffURL: PatchURL: IssueURL: Number:0 State: Locked:false Title: User:{Login: ID:0 AvatarURL: GravatarID: URL: HTMLURL: FollowersURL: FollowingURL: GistsURL: StarredURL: SubscriptionsURL: OrganizationsURL: ReposURL: EventsURL: ReceivedEventsURL: Type: SiteAdmin:false} Body: CreatedAt:0001-01-01 00:00:00 +0000 UTC UpdatedAt:0001-01-01 00:00:00 +0000 UTC ClosedAt:<nil> MergedAt:<nil> MergeCommitSha:<nil> Assignee:<nil> Milestone:<nil> CommitsURL: ReviewCommentsURL: ReviewCommentURL: CommentsURL: StatusesURL: Head:{Label: Ref: Sha: User:{Login: ID:0 AvatarURL: GravatarID: URL: HTMLURL: FollowersURL: FollowingURL: GistsURL: StarredURL: SubscriptionsURL: OrganizationsURL: ReposURL: EventsURL: ReceivedEventsURL: Type: SiteAdmin:false} Repo:{ID:0 Name: FullName: Owner:{Login: ID:0 AvatarURL: GravatarID: URL: HTMLURL: FollowersURL: FollowingURL: GistsURL: StarredURL: SubscriptionsURL: OrganizationsURL: ReposURL: EventsURL: ReceivedEventsURL: Type: SiteAdmin:false} Private:false HTMLURL: Description: Fork:false URL: ForksURL: KeysURL: CollaboratorsURL: TeamsURL: HooksURL: IssueEventsURL: EventsURL: AssigneesURL: BranchesURL: TagsURL: BlobsURL: GitTagsURL: GitRefsURL: TreesURL: StatusesURL: LanguagesURL: StargazersURL: ContributorsURL: SubscribersURL: SubscriptionURL: CommitsURL: GitCommitsURL: CommentsURL: IssueCommentURL: ContentsURL: CompareURL: MergesURL: ArchiveURL: DownloadsURL: IssuesURL: PullsURL: MilestonesURL: NotificationsURL: LabelsURL: ReleasesURL: CreatedAt:0001-01-01 00:00:00 +0000 UTC UpdatedAt:0001-01-01 00:00:00 +0000 UTC PushedAt:0001-01-01 00:00:00 +0000 UTC GitURL: SSHURL: CloneURL: SvnURL: Homepage:<nil> Size:0 StargazersCount:0 WatchersCount:0 Language:<nil> HasIssues:false HasDownloads:false HasWiki:false HasPages:false ForksCount:0 MirrorURL:<nil> OpenIssuesCount:0 Forks:0 OpenIssues:0 Watchers:0 DefaultBranch:}} Base:{Label: Ref: Sha: User:{Login: ID:0 AvatarURL: GravatarID: URL: HTMLURL: FollowersURL: FollowingURL: GistsURL: StarredURL: SubscriptionsURL: OrganizationsURL: ReposURL: EventsURL: ReceivedEventsURL: Type: SiteAdmin:false} Repo:{ID:0 Name: FullName: Owner:{Login: ID:0 AvatarURL: GravatarID: URL: HTMLURL: FollowersURL: FollowingURL: GistsURL: StarredURL: SubscriptionsURL: OrganizationsURL: ReposURL: EventsURL: ReceivedEventsURL: Type: SiteAdmin:false} Private:false HTMLURL: Description: Fork:false URL: ForksURL: KeysURL: CollaboratorsURL: TeamsURL: HooksURL: IssueEventsURL: EventsURL: AssigneesURL: BranchesURL: TagsURL: BlobsURL: GitTagsURL: GitRefsURL: TreesURL: StatusesURL: LanguagesURL: StargazersURL: ContributorsURL: SubscribersURL: SubscriptionURL: CommitsURL: GitCommitsURL: CommentsURL: IssueCommentURL: ContentsURL: CompareURL: MergesURL: ArchiveURL: DownloadsURL: IssuesURL: PullsURL: MilestonesURL: NotificationsURL: LabelsURL: ReleasesURL: CreatedAt:0001-01-01 00:00:00 +0000 UTC UpdatedAt:0001-01-01 00:00:00 +0000 UTC PushedAt:0001-01-01 00:00:00 +0000 UTC GitURL: SSHURL: CloneURL: SvnURL: Homepage:<nil> Size:0 StargazersCount:0 WatchersCount:0 Language:<nil> HasIssues:false HasDownloads:false HasWiki:false HasPages:false ForksCount:0 MirrorURL:<nil> OpenIssuesCount:0 Forks:0 OpenIssues:0 Watchers:0 DefaultBranch:}} Links:{Self:{Href:} HTML:{Href:} Issue:{Href:} Comments:{Href:} ReviewComments:{Href:} ReviewComment:{Href:} Commits:{Href:} Statuses:{Href:}} Merged:false Mergeable:<nil> MergeableState: MergedBy:<nil> Comments:0 ReviewComments:0 Commits:0 Additions:0 Deletions:0 ChangedFiles:0} Label:{ID:0 URL: Name: Color: Default:false} Repository:{ID:0 Name: FullName: Owner:{Login: ID:0 AvatarURL: GravatarID: URL: HTMLURL: FollowersURL: FollowingURL: GistsURL: StarredURL: SubscriptionsURL: OrganizationsURL: ReposURL: EventsURL: ReceivedEventsURL: Type: SiteAdmin:false} Private:false HTMLURL: Description: Fork:false URL: ForksURL: KeysURL: CollaboratorsURL: TeamsURL: HooksURL: IssueEventsURL: EventsURL: AssigneesURL: BranchesURL: TagsURL: BlobsURL: GitTagsURL: GitRefsURL: TreesURL: StatusesURL: LanguagesURL: StargazersURL: ContributorsURL: SubscribersURL: SubscriptionURL: CommitsURL: GitCommitsURL: CommentsURL: IssueCommentURL: ContentsURL: CompareURL: MergesURL: ArchiveURL: DownloadsURL: IssuesURL: PullsURL: MilestonesURL: NotificationsURL: LabelsURL: ReleasesURL: CreatedAt:0001-01-01 00:00:00 +0000 UTC UpdatedAt:0001-01-01 00:00:00 +0000 UTC PushedAt:0001-01-01 00:00:00 +0000 UTC GitURL: SSHURL: CloneURL: SvnURL: Homepage:<nil> Size:0 StargazersCount:0 WatchersCount:0 Language:<nil> HasIssues:false HasDownloads:false HasWiki:false HasPages:false ForksCount:0 MirrorURL:<nil> OpenIssuesCount:0 Forks:0 OpenIssues:0 Watchers:0 DefaultBranch:} Sender:{Login: ID:0 AvatarURL: GravatarID: URL: HTMLURL: FollowersURL: FollowingURL: GistsURL: StarredURL: SubscriptionsURL: OrganizationsURL: ReposURL: EventsURL: ReceivedEventsURL: Type: SiteAdmin:false} Installation:{ID:0}}

Thanks for your help!

Hey @kuiro5 for reporting, I will take a look ASAP, been a crazy week though probably won’t get a chance for a few days; if you’d like to take a stab at a fix that would be amazing!

I hit this same exact issue. The weird thing is, the payload looks correct, no unmarshalling issues should take place, but everything in my PushEvent is of nil type. I'm digging into it this evening and will update.

@kuiro5 - check your webhook settings in github, you get a choice of urlencoded header or application/json. You want application/json. There's a dropdown menu that defaults to the former when you setup the new webhook URL for your org or repo.

@kuiro5 did @malnick's work?

@joeybloggs @malnick Yes! This seemed to fix it, thank you for the help 👍