Skip to content

Commit 992727b

Browse files
committed
chore: allow prebuilds user to be added to group
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
1 parent 0a3e9a9 commit 992727b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

enterprise/coderd/groups.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/coder/coder/v2/coderd/database/db2sdk"
1515
"github.com/coder/coder/v2/coderd/httpapi"
1616
"github.com/coder/coder/v2/coderd/httpmw"
17+
"github.com/coder/coder/v2/coderd/prebuilds"
1718
"github.com/coder/coder/v2/codersdk"
1819
)
1920

@@ -165,16 +166,19 @@ func (api *API) patchGroup(rw http.ResponseWriter, r *http.Request) {
165166
aReq.Old = group.Auditable(currentMembers)
166167

167168
for _, id := range users {
168-
if _, err := uuid.Parse(id); err != nil {
169+
uid, err := uuid.Parse(id)
170+
if err != nil {
169171
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
170172
Message: fmt.Sprintf("ID %q must be a valid user UUID.", id),
171173
})
172174
return
173175
}
174-
_, err := database.ExpectOne(api.Database.OrganizationMembers(ctx, database.OrganizationMembersParams{
176+
177+
isSystemUser := uid == prebuilds.SystemUserID
178+
_, err = database.ExpectOne(api.Database.OrganizationMembers(ctx, database.OrganizationMembersParams{
175179
OrganizationID: group.OrganizationID,
176-
UserID: uuid.MustParse(id),
177-
IncludeSystem: false,
180+
UserID: uid,
181+
IncludeSystem: isSystemUser,
178182
}))
179183
if errors.Is(err, sql.ErrNoRows) {
180184
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{

0 commit comments

Comments
 (0)