Skip to content

Commit 93bd6ed

Browse files
committed
Handle AS users with invalid localparts edge case
1 parent 7d060f5 commit 93bd6ed

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

crates/syn2mas/src/migration.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,20 @@ async fn migrate_users(
181181

182182
while let Some(user_res) = users_stream.next().await {
183183
let user = user_res.into_synapse("reading user")?;
184+
185+
// Handling an edge case: some AS users may have invalid localparts containing
186+
// extra `:` characters. These users are ignored and a warning is logged.
187+
if user.appservice_id.is_some()
188+
&& user
189+
.name
190+
.0
191+
.strip_suffix(&format!(":{}", state.server_name))
192+
.is_some_and(|localpart| localpart.contains(':'))
193+
{
194+
tracing::warn!("AS user {} has invalid localpart, ignoring!", user.name.0);
195+
continue;
196+
}
197+
184198
let (mas_user, mas_password_opt) = transform_user(&user, &state.server_name, rng)?;
185199

186200
let mut flags = UserFlags::empty();

0 commit comments

Comments
 (0)