Skip to content

Commit c4d4a8c

Browse files
authored
Fix bug with incorrect request payload for groups (Branch Restrictions) (#172)
The API expects the group slug to be passed in, without this, API returns a HTTP 400 error. Also, fixed `branchRestrictionsBodyGroup` struct, specifically the inner `links` struct which accidentally included `full_slug` & `slug` - both of which should be at the root level. Previously a request with this payload ``` {"kind":"push","pattern":"develop","links":{"self":{"href":""}},"value":null,"id":0,"users":null,"groups":[{"name":"za-test"}]} ``` Would return ``` {"type":"error","error":{"message":"malformed groups"}} ``` With the fixed payload, we now get a success response. ``` {"kind":"push","pattern":"develop","links":{"self":{"href":""}},"value":null,"id":0,"users":null,"groups":[{"slug":"za-test"}]} ```
1 parent 3feff68 commit c4d4a8c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

branchrestrictions.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@ type branchRestrictionsBodyGroup struct {
8282
Html struct {
8383
Href string `json:"href"`
8484
} `json:"html"`
85-
FullSlug string `json:"full_slug"`
86-
Members int `json:"members"`
87-
Slug string `json:"slug"`
8885
} `json:"links"`
86+
FullSlug string `json:"full_slug"`
87+
Slug string `json:"slug"`
8988
}
9089

9190
type branchRestrictionsBodyUser struct {
@@ -128,7 +127,7 @@ func (b *BranchRestrictions) buildBranchRestrictionsBody(bo *BranchRestrictionsO
128127
}
129128
for _, g := range bo.Groups {
130129
group := branchRestrictionsBodyGroup{
131-
Name: g,
130+
Slug: g,
132131
}
133132
groups = append(groups, group)
134133
}

0 commit comments

Comments
 (0)