Skip to content

Commit 1258902

Browse files
authored
chore: update error message for duplicate organization members (#17594)
Closes coder/internal#345
1 parent a78f0fc commit 1258902

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

coderd/members.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ func (api *API) postOrganizationMember(rw http.ResponseWriter, r *http.Request)
6262
}
6363
if database.IsUniqueViolation(err, database.UniqueOrganizationMembersPkey) {
6464
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
65-
Message: "Organization member already exists in this organization",
65+
Message: "User is already an organization member",
66+
Detail: fmt.Sprintf("%s is already a member of %s", user.Username, organization.DisplayName),
6667
})
6768
return
6869
}

coderd/members_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestAddMember(t *testing.T) {
2626
// Add user to org, even though they already exist
2727
// nolint:gocritic // must be an owner to see the user
2828
_, err := owner.PostOrganizationMember(ctx, first.OrganizationID, user.Username)
29-
require.ErrorContains(t, err, "already exists")
29+
require.ErrorContains(t, err, "already an organization member")
3030
})
3131
}
3232

0 commit comments

Comments
 (0)