Bug: username fallback in updateUserUsername never runs since the ddp-client migration
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript, react
調査の方向性
packages/api/src/EmbeddedChatApi.ts の updateUserUsername() と _restRequest() から始め、API クライアントが 400 応答をどのように拒否するかを確認してください。そのエラー形式を、issue で説明されているサーバーの error-could-not-save-identity 応答と比較してください。その応答に対してユーザー名候補のフォールバックが実行されるよう、エラー処理を更新してください。その後、使用済みのユーザー名でフォールバックが実行され、その他のエラーは引き続きログに記録されることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- JavaScript
- スター
- 171
- フォーク
- 421
- 平均マージ
- 3日 6時間
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
RocketChat/EmbeddedChat のほかの issue
-
[Bug]: Low contrast on color swatch borders in Theme Lab (Layout Editor)対応中かも @yashsarvaiya45 が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
RocketChat/EmbeddedChat#1486 ·
メンテナーはふだん 1 日以内に返信
-
bug(api): _doConnect swallows connection/auth errors and marks failed sessions as authenticated対応中かも @ashwanisingh011 が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
RocketChat/EmbeddedChat#1484 ·
メンテナーはふだん 1 日以内に返信
-
Bug: White screen crash (`Cannot read properties of undefined (reading 'members')`) when rendering UserMention outside MarkupInteractionContext対応中かも @swarnendusahu10-dotcom が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
RocketChat/EmbeddedChat#1482 ·
メンテナーはふだん 1 日以内に返信
-
Bug: UIKit PreviewBlock cover image tiles repeatedly and stretches across viewport when zoomed out対応中かも @swarnendusahu10-dotcom が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
RocketChat/EmbeddedChat#1480 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
ug(react): guard against null childElement in MessageAggregator setJumpToMessage対応中かも @Suraj704-glitch が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
RocketChat/EmbeddedChat#1478 ·
メンテナーはふだん 1 日以内に返信
RocketChat/EmbeddedChat の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
[Docs] CONTRIBUTING.md links to retired GitHub Learning Lab and Try Git sites対応中かも @adityamukesh が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
reillywalter/win-dev-doctor#92 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100