Bug: username fallback in updateUserUsername never runs since the ddp-client migration
Mantenedores costumam responder em até 1 dia
@MuhammadFaizan-prog já está trabalhando nisso.
Desde 4/12/2026.
- #1490 de @MuhammadFaizan-prog — aberto
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 78/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- javascript, react
- Domínio
- authentication, backend
Direção de pesquisa
Comece em packages/api/src/EmbeddedChatApi.ts, em updateUserUsername() e _restRequest(), e verifique como o cliente da API rejeita respostas 400. Compare esse formato de erro com a resposta do servidor error-could-not-save-identity descrita na issue. Atualize o tratamento de erros para que o fallback de sugestão de nome de usuário seja executado para essa resposta. Em seguida, verifique se um nome de usuário já ocupado aciona o fallback e se os outros erros continuam sendo registrados.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- JavaScript
- Estrelas
- 171
- Forks
- 421
- Merge médio
- 3d 6h
- PRs com merge (30d)
- 4
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Sem guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de RocketChat/EmbeddedChat
-
[Bug]: Low contrast on color swatch borders in Theme Lab (Layout Editor)Talvez já em andamento @yashsarvaiya45 assumiu hoje. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 79/100
RocketChat/EmbeddedChat#1486 ·
Mantenedores costumam responder em até 1 dia
-
bug(api): _doConnect swallows connection/auth errors and marks failed sessions as authenticatedTalvez já em andamento @ashwanisingh011 assumiu há 1 dia. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
RocketChat/EmbeddedChat#1484 ·
Mantenedores costumam responder em até 1 dia
-
Bug: White screen crash (`Cannot read properties of undefined (reading 'members')`) when rendering UserMention outside MarkupInteractionContextTalvez já em andamento @swarnendusahu10-dotcom assumiu há 2 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
RocketChat/EmbeddedChat#1482 ·
Mantenedores costumam responder em até 1 dia
-
Bug: UIKit PreviewBlock cover image tiles repeatedly and stretches across viewport when zoomed outTalvez já em andamento @swarnendusahu10-dotcom assumiu há 3 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
RocketChat/EmbeddedChat#1480 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
ug(react): guard against null childElement in MessageAggregator setJumpToMessageTalvez já em andamento @Suraj704-glitch assumiu há 4 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
RocketChat/EmbeddedChat#1478 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de RocketChat/EmbeddedChat
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
-
[Docs] CONTRIBUTING.md links to retired GitHub Learning Lab and Try Git sitesTalvez já em andamento @adityamukesh assumiu hoje. Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
-
enhancement good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
reillywalter/win-dev-doctor#92 ·
Mantenedores costumam responder em até 1 dia
-
[Feature] 新增「查看完整听歌设备记录」接口Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100