Bug: username fallback in updateUserUsername never runs since the ddp-client migration
Maintainer antworten meist innerhalb von 1 Tag
@MuhammadFaizan-prog arbeitet bereits daran.
Seit 04.12.2026.
- #1490 von @MuhammadFaizan-prog — offen
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 78/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- javascript, react
- Bereich
- authentication, backend
Rechercherichtung
Beginne in packages/api/src/EmbeddedChatApi.ts bei updateUserUsername() und _restRequest() und prüfe, wie der API-Client 400-Antworten zurückweist. Vergleiche diese Fehlerstruktur mit der im Issue beschriebenen Antwort des Servers error-could-not-save-identity. Aktualisiere die Fehlerbehandlung, damit der Fallback für den Benutzernamenvorschlag bei dieser Antwort ausgeführt wird. Verifiziere anschließend, dass ein bereits vergebener Benutzername den Fallback auslöst und andere Fehler weiterhin protokolliert werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Description:
Users who log in without a username (for example through Google SSO) go through updateUserUsername() in packages/api/src/EmbeddedChatApi.ts (lines 500 to 519). It turns the display name into a username and saves it with users.update. If that username is already taken, the catch block checks err?.errorType === "error-could-not-save-identity" and falls back to updateUserNameThroughSuggestion().
Since #1308 the request goes through _restRequest(), which calls this.sdk.rest.send(). In @rocket.chat/api-client 0.2.56 (the version yarn.lock resolves), send() rejects with the raw Response object on a 400, not the parsed JSON body:
if (response.ok) { return response; }
if (response.status !== 400) { return Promise.reject(response); }
// ...2FA retry check...
return Promise.reject(response);
So err is a Response, err.errorType is always undefined, and the fallback never runs. The error is only logged, and it shows up as [object Response].
On the server side, a taken username on users.update does produce that error type: _setUsername() returns false when checkUsernameAvailability() fails, and saveUser() turns that into a 400 with errorType: "error-could-not-save-identity".
Before #1308 this worked, because the code called fetch directly and read result.errorType from await response.json().
Steps to reproduce:
- Have a user whose display name maps to a username that already exists (for example display name "John Doe" while
john.doeis taken). - Log that user in through an SSO provider that creates the account without a username.
updateUserUsername()callsusers.updatewithjohn.doe, and the server answers 400error-could-not-save-identity.
Expected behavior:
The catch block sees errorType: "error-could-not-save-identity" and sets a username from users.getUsernameSuggestion, as it did before #1308.
Actual behavior:
The fallback is skipped. The user is left without a username and the console shows [object Response].
A possible fix is to read the body in the catch, for example const body = err instanceof Response ? await err.json().catch(() => ({})) : err; and check body?.errorType, or to do that once in _restRequest() so every caller gets the parsed error.
This is not the regex anchor problem in the same function, which #1201, #1202 and #1388 already cover. Found by reading the code against @rocket.chat/api-client 0.2.56 and Rocket.Chat develop; I have not reproduced it against a live server.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 171
- Forks
- 421
- Ø Merge
- 3 T. 6 Std.
- Gemergte PRs (30 T.)
- 4
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus RocketChat/EmbeddedChat
-
[Bug]: Low contrast on color swatch borders in Theme Lab (Layout Editor)Evtl. vergeben @yashsarvaiya45 hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
RocketChat/EmbeddedChat#1486 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug(api): _doConnect swallows connection/auth errors and marks failed sessions as authenticatedEvtl. vergeben @ashwanisingh011 hat das vor 1 Tag übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
RocketChat/EmbeddedChat#1484 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug: White screen crash (`Cannot read properties of undefined (reading 'members')`) when rendering UserMention outside MarkupInteractionContextEvtl. vergeben @swarnendusahu10-dotcom hat das vor 2 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
RocketChat/EmbeddedChat#1482 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug: UIKit PreviewBlock cover image tiles repeatedly and stretches across viewport when zoomed outEvtl. vergeben @swarnendusahu10-dotcom hat das vor 3 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
RocketChat/EmbeddedChat#1480 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
ug(react): guard against null childElement in MessageAggregator setJumpToMessageEvtl. vergeben @Suraj704-glitch hat das vor 4 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
RocketChat/EmbeddedChat#1478 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in RocketChat/EmbeddedChat
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
[Docs] CONTRIBUTING.md links to retired GitHub Learning Lab and Try Git sitesEvtl. vergeben @adityamukesh hat das heute übernommen. Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
-
enhancement good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
reillywalter/win-dev-doctor#92 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100