[Bug]: Connected Workspaces shared-channel member sync fails when RestrictCreationToDomains is enabled
Before you file a bug report
- I have checked the issue tracker and have not found an issue that matches the one I'm filing.
- This issue is not a troubleshooting question. Troubleshooting questions go here: https://forum.mattermost.com/c/trouble-shoot/16.
- This issue is not a feature request. You can request features and make product suggestions here: https://mattermost.uservoice.com/forums/306457-general/.
- This issue reproduces on one of the currently supported server versions.
- I have read the contribution guidelines and the Mattermost Handbook Contribution Guidelines.
Mattermost Server Version
11.10.1
Operating System
Ubuntu 24.04 LTS
Steps to reproduce
- Connect two Mattermost instances using Connected Workspaces.
- Enable
TeamSettings.RestrictCreationToDomainson the receiving workspace and include the remote user's actual email domain in the allowed list. - Share a channel between the workspaces.
- Add a remote user whose real email belongs to the allowed remote domain.
- Trigger shared-channel member synchronization.
- Observe that the Remote Cluster remains healthy, but the remote user is not added to the local team/shared channel.
- Check the receiving workspace logs and observe a
JoinUserToTeamfailure caused by domain validation. - Inspect the remote user on the receiving workspace and note that
users.emailcontains a generated synthetic value while the actual email is stored inprops.RemoteEmail.
Expected behavior
A Connected Workspaces remote user whose real email belongs to a domain listed in TeamSettings.RestrictCreationToDomains should be successfully added to the local team and shared channel.
The synthetic local representation of the remote user's email should not cause domain validation to fail.
Observed behavior
Shared-channel member synchronization fails during the local team membership step.
The remote user's actual email is preserved in props.RemoteEmail, while users.email contains a generated synthetic value without an email domain.
The team domain validation appears to be performed against users.email, causing the remote user to fail the domain check even though props.RemoteEmail belongs to a domain explicitly allowed by TeamSettings.RestrictCreationToDomains.
As a result, the remote user exists on the receiving workspace, but no corresponding team/channel membership is created.
Log Output
Error upserting sync user
caller="sharedchannel/sync_recv.go:145"
remote=<remote>
channel_id=<channel_id>
user_id=<user_id>
error="error adding sync user to Team: JoinUserToTeam: the user cannot be added as the domain associated with the account is not permitted"
Failed to process membership change
caller="sharedchannel/membership_recv.go:79"
user_id=<user_id>
channel_id=<channel_id>
remote_id=<remote_cluster_id>
is_add=true
error="cannot upsert user for channel add: error adding sync user to Team: JoinUserToTeam: the user cannot be added as the domain associated with the account is not permitted"
Some membership changes failed
caller="sharedchannel/membership_recv.go:92"Additional Information
The team itself has no team-specific domain restriction: teams.alloweddomains = ''.
MM_FEATUREFLAGS_ENABLESHAREDCHANNELSDMS=true MM_FEATUREFLAGS_ENABLESYNCALLUSERSFORREMOTECLUSTER=true MM_FEATUREFLAGS_ENABLESHAREDCHANNELSMEMBERSYNC=true This parameters is enabled on both workspaces.
The remote user's actual domain is explicitly included in TeamSettings.RestrictCreationToDomains.
On the source workspace, the user has a normal email such as [email protected]. On the receiving workspace, the same remote user is represented approximately as:
users.email = <generated synthetic ID>
props.RemoteEmail = [email protected]
The Remote Cluster connection itself is healthy. The failure occurs specifically while adding the synchronized remote user to the receiving workspace team.
A possible fix would be to use props.RemoteEmail for domain-policy validation when the user is a Connected Workspaces remote user, while continuing to keep the synthetic value in users.email.
This seems preferable to bypassing RestrictCreationToDomains entirely, because the configured domain policy would still be enforced.
Source: mattermost/mattermost