Skip to content

Commit d13f8f5

Browse files
committed
Fix for deletion logic and tighter schema
1 parent d1110c5 commit d13f8f5

File tree

2 files changed

+16
-6
lines changed
  • apps/webapp/app/routes
    • _app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.errors.$fingerprint
    • _app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.errors

2 files changed

+16
-6
lines changed

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.errors.$fingerprint/route.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,20 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
8080
const actionSchema = z.discriminatedUnion("action", [
8181
z.object({
8282
action: z.literal("resolve"),
83-
taskIdentifier: z.string(),
83+
taskIdentifier: z.string().min(1),
8484
resolvedInVersion: z.string().optional(),
8585
}),
8686
z.object({
8787
action: z.literal("ignore"),
88-
taskIdentifier: z.string(),
89-
duration: z.coerce.number().optional(),
90-
occurrenceRate: z.coerce.number().optional(),
91-
totalOccurrences: z.coerce.number().optional(),
88+
taskIdentifier: z.string().min(1),
89+
duration: z.coerce.number().positive().optional(),
90+
occurrenceRate: z.coerce.number().positive().optional(),
91+
totalOccurrences: z.coerce.number().positive().optional(),
9292
reason: z.string().optional(),
9393
}),
9494
z.object({
9595
action: z.literal("unresolve"),
96-
taskIdentifier: z.string(),
96+
taskIdentifier: z.string().min(1),
9797
}),
9898
]);
9999

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.errors/route.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ErrorAlertChannelPresenter } from "~/presenters/v3/ErrorAlertChannelPre
1717
import { findProjectBySlug } from "~/models/project.server";
1818
import { findEnvironmentBySlug } from "~/models/runtimeEnvironment.server";
1919
import { requireUserId } from "~/services/session.server";
20+
import { env } from "~/env.server";
2021
import { EnvironmentParamSchema, v3ErrorsConnectToSlackPath } from "~/utils/pathBuilder";
2122
import {
2223
type CreateAlertChannelOptions,
@@ -137,9 +138,18 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
137138
processedChannelIds.add(channel.id);
138139
}
139140

141+
const editableTypes = new Set<string>(["WEBHOOK"]);
142+
if (env.ALERT_FROM_EMAIL !== undefined && env.ALERT_RESEND_API_KEY !== undefined) {
143+
editableTypes.add("EMAIL");
144+
}
145+
if (slackIntegrationId) {
146+
editableTypes.add("SLACK");
147+
}
148+
140149
const channelsToDelete = existingChannels.filter(
141150
(ch) =>
142151
!processedChannelIds.has(ch.id) &&
152+
editableTypes.has(ch.type) &&
143153
ch.alertTypes.length === 1 &&
144154
ch.alertTypes[0] === "ERROR_GROUP"
145155
);

0 commit comments

Comments
 (0)