Files
32d6add42f [MM-62445] Allow changing a team's name (slug) via mmctl team rename (#37169)
* Allow renaming a team's name (slug) via the team update API

The team update API path is sanitized and intentionally ignores the
Name field, so the previously orphaned RenameTeam app method (which no
longer persisted the Name change) is now wired into the updateTeam
handler and fixed to persist the new slug and emit a team update event.

Co-authored-by: mattermost-code <[email protected]>

* Add --name flag to mmctl team rename

Allow changing a team's name (the URL slug) via mmctl team rename. The
command now accepts --name and/or --display-name, and at least one must
be provided.

Co-authored-by: mattermost-code <[email protected]>

* Polish team rename error message and fix err shadow

Co-authored-by: mattermost-code <[email protected]>

* Strengthen team rename tests

Add regression coverage that the rename path cannot leak non-renamable
fields (email/type), that invalid and duplicate renames leave the slug
unchanged, and a unit case for renaming name and display name together.

Co-authored-by: mattermost-code <[email protected]>

* Address PR feedback: 1 answered, 1 resolved, 0 declined

* Remove unused App.RenameTeam method

The rename path now goes through App.UpdateTeam (via the team update API
and mmctl), leaving App.RenameTeam orphaned. Remove it and update the
name-occupied error source label to UpdateTeam.

* Return non-not-found errors from team name lookup

Only treat store.ErrNotFound from GetByName as an available slug; any
other lookup failure is now returned instead of silently allowing the
rename to proceed. Addresses CodeRabbit review feedback on the team
update path.

* Remove low-value TestUpdateTeamNameLookupError per review feedback

---------

Co-authored-by: mattermost-code <[email protected]>

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-10 09:11:17 +02:00

29 lines
728 B
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package teams
import "errors"
var (
AcceptedDomainError = errors.New("the user cannot be added as the domain associated with the account is not permitted")
MemberCountError = errors.New("unable to count the team members")
MaxMemberCountError = errors.New("reached to the maximum number of allowed accounts")
)
type DomainError struct {
Domain string
}
func (DomainError) Error() string {
return "restricting team to the domain, it is not allowed by the system config"
}
type NameOccupiedError struct {
Name string
}
func (NameOccupiedError) Error() string {
return "team name is already occupied"
}