Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Revert "refactor(reminders): name the uuid pattern in the orphan alert query and explain the cast"

Calvin24985a6b3a5c
diff --git a/backend/src/services/reminder/reminder-dal.ts b/backend/src/services/reminder/reminder-dal.ts
index ae39e2d4cd..4c30d7cf76 100644
--- a/backend/src/services/reminder/reminder-dal.ts
+++ b/backend/src/services/reminder/reminder-dal.ts
@@ -5,8 +5,6 @@ import { TableName, TProjectEnvironments, TProjects, TSecretFolders, TSecretsV2
import { RemindersSchema } from "@app/db/schemas/reminders";
import { ormify, selectAllTableCols } from "@app/lib/knex";
-const UUID_PATTERN = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
-
export type TReminderDALFactory = ReturnType<typeof reminderDALFactory>;
export const reminderDALFactory = (db: TDbClient) => {
@@ -52,12 +50,9 @@ export const reminderDALFactory = (db: TDbClient) => {
void qb
.select(db.raw("1"))
.from(TableName.SecretV2)
- // alerts.resourceId is text and secrets_v2.id is a uuid, so the id is cast to compare them. The
- // cast only runs on values shaped like a uuid, so a malformed id becomes NULL (and is reaped)
- // instead of failing the whole query.
+ // The CASE keeps a non-uuid resourceId from failing the cast for the whole query.
.whereRaw(
- `"${TableName.SecretV2}"."id" = CASE WHEN "${TableName.Alert}"."resourceId" ~* ? THEN "${TableName.Alert}"."resourceId"::uuid END`,
- [UUID_PATTERN]
+ `"${TableName.SecretV2}"."id" = CASE WHEN "${TableName.Alert}"."resourceId" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' THEN "${TableName.Alert}"."resourceId"::uuid END`
);
})
.limit(limit)