Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

people: Use safePrase to parse error response.

Aman Agrawalc1e308186070
diff --git a/web/src/people.ts b/web/src/people.ts
index 0af952865b0..465718624f0 100644
--- a/web/src/people.ts
+++ b/web/src/people.ts
@@ -1964,9 +1964,11 @@ export async function fetch_users(user_ids: Set<number>): Promise<UsersFetchResp
error(xhr) {
let error_message = "Failed to fetch users.";
if (xhr) {
- const error = z.object({msg: z.string().optional()}).parse(xhr.responseJSON);
- if (error.msg) {
- error_message = error.msg;
+ const error = z
+ .object({msg: z.string().optional()})
+ .safeParse(xhr.responseJSON);
+ if (error.success && error.data.msg) {
+ error_message = error.data.msg;
}
}
blueslip.error(error_message);