Webhooks not sending all data
This is on the public GitLab so I think it's the enterprise edition (sorry if that's not correct).
Summary
I could be doing something 100% incorrect, but I'm not getting all of the data from webhooks. If I click the test button, I get everything. However, if I just create an issue or a merge request I don't get hardly any data in the payload.
Steps to reproduce
Create issue webhook and click test. Then create an actual issue and submit it.
What is the current bug behavior?
Clicking the test button works fine, but creating the issue (which I believe should be the same) only gives a very small amount of data.
What is the expected correct behavior?
All of the relevant JSON fields should be filled.
Relevant logs and/or screenshots
Clicking test:
Actually creating an issue:
Here's the struct and just the code used to log:
// Package p contains an HTTP Cloud Function.
package p
import (
"encoding/json"
"fmt"
"html"
"io/ioutil"
"log"
"net/http"
"time"
)
type GitLab struct {
ObjectKind string `json:"object_kind"`
User struct {
Name string `json:"name"`
Username string `json:"username"`
AvatarURL string `json:"avatar_url"`
} `json:"user"`
Project struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
WebURL string `json:"web_url"`
AvatarURL interface{} `json:"avatar_url"`
GitSSHURL string `json:"git_ssh_url"`
GitHTTPURL string `json:"git_http_url"`
Namespace string `json:"namespace"`
VisibilityLevel int `json:"visibility_level"`
PathWithNamespace string `json:"path_with_namespace"`
DefaultBranch string `json:"default_branch"`
Homepage string `json:"homepage"`
URL string `json:"url"`
SSHURL string `json:"ssh_url"`
HTTPURL string `json:"http_url"`
} `json:"project"`
Repository struct {
Name string `json:"name"`
URL string `json:"url"`
Description string `json:"description"`
Homepage string `json:"homepage"`
} `json:"repository"`
ObjectAttributes struct {
ID int `json:"id"`
Title string `json:"title"`
AssigneeIds []int `json:"assignee_ids"`
AssigneeID int `json:"assignee_id"`
AuthorID int `json:"author_id"`
ProjectID int `json:"project_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Position int `json:"position"`
BranchName interface{} `json:"branch_name"`
Description string `json:"description"`
MilestoneID interface{} `json:"milestone_id"`
State string `json:"state"`
Iid int `json:"iid"`
URL string `json:"url"`
Action string `json:"action"`
} `json:"object_attributes"`
Assignees []struct {
Name string `json:"name"`
Username string `json:"username"`
AvatarURL string `json:"avatar_url"`
} `json:"assignees"`
Assignee struct {
Name string `json:"name"`
Username string `json:"username"`
AvatarURL string `json:"avatar_url"`
} `json:"assignee"`
Labels []struct {
ID int `json:"id"`
Title string `json:"title"`
Color string `json:"color"`
ProjectID int `json:"project_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Template bool `json:"template"`
Description string `json:"description"`
Type string `json:"type"`
GroupID int `json:"group_id"`
} `json:"labels"`
Changes struct {
UpdatedByID struct {
Previous interface{} `json:"previous"`
Current int `json:"current"`
} `json:"updated_by_id"`
UpdatedAt struct {
Previous string `json:"previous"`
Current string `json:"current"`
} `json:"updated_at"`
Labels struct {
Previous []struct {
ID int `json:"id"`
Title string `json:"title"`
Color string `json:"color"`
ProjectID int `json:"project_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Template bool `json:"template"`
Description string `json:"description"`
Type string `json:"type"`
GroupID int `json:"group_id"`
} `json:"previous"`
Current []struct {
ID int `json:"id"`
Title string `json:"title"`
Color string `json:"color"`
ProjectID int `json:"project_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Template bool `json:"template"`
Description string `json:"description"`
Type string `json:"type"`
GroupID int `json:"group_id"`
} `json:"current"`
} `json:"labels"`
} `json:"changes"`
}
func GLTest(w http.ResponseWriter, r *http.Request) {
var gitlab GitLab
body, err := ioutil.ReadAll(r.Body)
if err != nil {
log.Panic(err)
}
json.Unmarshal(body, &gitlab)
fmt.Fprint(w, html.EscapeString(gitlab.User.Name))
log.Print(gitlab.Repository.Name)
log.Print(gitlab.User.Username)
log.Print(gitlab.ObjectAttributes.Title)
log.Print(gitlab.ObjectAttributes.AuthorID)
log.Print(gitlab.ObjectAttributes.URL)
log.Print(gitlab.ObjectAttributes.Description)
log.Print(gitlab)
}
I apologize in advance if I'm just stupid.
Edited by John Hooks