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.

ui_report: Fix implicit use of any.

Anders Kaseorg328f24609255
diff --git a/web/src/ui_report.ts b/web/src/ui_report.ts
index 9a980f6c496..a00bfbcd93e 100644
--- a/web/src/ui_report.ts
+++ b/web/src/ui_report.ts
@@ -1,4 +1,5 @@
import $ from "jquery";
+import {z} from "zod";
import * as channel from "./channel";
import * as common from "./common";
@@ -68,8 +69,13 @@ export function generic_embed_error(error_html: string, remove_after: number): v
}
export function generic_row_button_error(xhr: JQuery.jqXHR, $btn: JQuery): void {
- if (xhr.status >= 400 && xhr.status < 500 && xhr.responseJSON?.msg) {
- const $error = $("<p>").addClass("text-error").text(xhr.responseJSON.msg);
+ let parsed;
+ if (
+ xhr.status >= 400 &&
+ xhr.status < 500 &&
+ (parsed = z.object({msg: z.string()}).safeParse(xhr.responseJSON)).success
+ ) {
+ const $error = $("<p>").addClass("text-error").text(parsed.data.msg);
$btn.closest("td").empty().append($error);
} else {
$btn.text($t({defaultMessage: "Failed!"}));