mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
chore: update error message for duplicate organization members (#17594)
Closes https://github.com/coder/internal/issues/345
This commit is contained in:
@ -62,7 +62,8 @@ func (api *API) postOrganizationMember(rw http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
if database.IsUniqueViolation(err, database.UniqueOrganizationMembersPkey) {
|
if database.IsUniqueViolation(err, database.UniqueOrganizationMembersPkey) {
|
||||||
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
|
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
|
||||||
Message: "Organization member already exists in this organization",
|
Message: "User is already an organization member",
|
||||||
|
Detail: fmt.Sprintf("%s is already a member of %s", user.Username, organization.DisplayName),
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ func TestAddMember(t *testing.T) {
|
|||||||
// Add user to org, even though they already exist
|
// Add user to org, even though they already exist
|
||||||
// nolint:gocritic // must be an owner to see the user
|
// nolint:gocritic // must be an owner to see the user
|
||||||
_, err := owner.PostOrganizationMember(ctx, first.OrganizationID, user.Username)
|
_, err := owner.PostOrganizationMember(ctx, first.OrganizationID, user.Username)
|
||||||
require.ErrorContains(t, err, "already exists")
|
require.ErrorContains(t, err, "already an organization member")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user