Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix(planned-downtime): notification breaking the page due to invalid description (#10492)

Vinicius Lourençof44a6aab9a4f
diff --git a/frontend/src/container/PlannedDowntime/PlannedDowntimeForm.tsx b/frontend/src/container/PlannedDowntime/PlannedDowntimeForm.tsx
index 43d46b4c40..28901cf7f0 100644
--- a/frontend/src/container/PlannedDowntime/PlannedDowntimeForm.tsx
+++ b/frontend/src/container/PlannedDowntime/PlannedDowntimeForm.tsx
@@ -33,6 +33,8 @@ import { ALL_TIME_ZONES } from 'utils/timeZoneUtil';
import 'dayjs/locale/en';
+import { SOMETHING_WENT_WRONG } from '../../constants/api';
+import { showErrorNotification } from '../../utils/error';
import { AlertRuleTags } from './PlannedDowntimeList';
import {
createEditDowntimeSchedule,
@@ -175,14 +177,14 @@ export function PlannedDowntimeForm(
} else {
notifications.error({
message: 'Error',
- description: response.error || 'unexpected_error',
+ description:
+ typeof response.error === 'string'
+ ? response.error
+ : response.error?.message || SOMETHING_WENT_WRONG,
});
}
- } catch (e) {
- notifications.error({
- message: 'Error',
- description: 'unexpected_error',
- });
+ } catch (e: unknown) {
+ showErrorNotification(notifications, e as Error);
}
setSaveLoading(false);
},
diff --git a/frontend/src/container/PlannedDowntime/PlannedDowntimeList.tsx b/frontend/src/container/PlannedDowntime/PlannedDowntimeList.tsx
index 6739cb40b6..349b670308 100644
--- a/frontend/src/container/PlannedDowntime/PlannedDowntimeList.tsx
+++ b/frontend/src/container/PlannedDowntime/PlannedDowntimeList.tsx
@@ -25,6 +25,7 @@ import { CalendarClock, PenLine, Trash2 } from 'lucide-react';
import { useAppContext } from 'providers/App/App';
import { USER_ROLES } from 'types/roles';
+import { showErrorNotification } from '../../utils/error';
import {
formatDateTime,
getAlertOptionsFromIds,
@@ -359,7 +360,7 @@ export function PlannedDowntimeList({
useEffect(() => {
if (downtimeSchedules.isError) {
- notifications.error(downtimeSchedules.error);
+ showErrorNotification(notifications, downtimeSchedules.error);
}
}, [downtimeSchedules.error, downtimeSchedules.isError, notifications]);
diff --git a/frontend/src/container/PlannedDowntime/PlannedDowntimeutils.ts b/frontend/src/container/PlannedDowntime/PlannedDowntimeutils.ts
index cc057d374a..a9a309b9a5 100644
--- a/frontend/src/container/PlannedDowntime/PlannedDowntimeutils.ts
+++ b/frontend/src/container/PlannedDowntime/PlannedDowntimeutils.ts
@@ -137,7 +137,10 @@ export const deleteDowntimeHandler = ({
export const createEditDowntimeSchedule = async (
props: DowntimeScheduleUpdatePayload,
-): Promise<SuccessResponse<PayloadProps> | ErrorResponse> => {
+): Promise<
+ | SuccessResponse<PayloadProps>
+ | ErrorResponse<{ code: string; message: string } | string>
+> => {
if (props.id) {
return updateDowntimeSchedule({ ...props });
}
diff --git a/frontend/src/types/api/index.ts b/frontend/src/types/api/index.ts
index 46be28207d..e58fd7dec4 100644
--- a/frontend/src/types/api/index.ts
+++ b/frontend/src/types/api/index.ts
@@ -3,10 +3,10 @@ import { ErrorStatusCode, SuccessStatusCode } from 'types/common';
export type ApiResponse<T> = { data: T };
-export interface ErrorResponse {
+export interface ErrorResponse<ErrorObject = string> {
statusCode: ErrorStatusCode;
payload: null;
- error: string;
+ error: ErrorObject;
message: string | null;
body?: string | null;
}