Skip to content

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

remove RE

Thiago Araujo da Silva346119deec61
diff --git a/backend/src/services/alert/alert-event-consumer.test.ts b/backend/src/services/alert/alert-event-consumer.test.ts
index 38b098f589..9444fef149 100644
--- a/backend/src/services/alert/alert-event-consumer.test.ts
+++ b/backend/src/services/alert/alert-event-consumer.test.ts
@@ -125,7 +125,7 @@ describe("alert outbox consumer", () => {
const [result] = await consumer.handle([makeRow({ payload: { targetIds: [] } })]);
expect(result.status).toBe(EventOutboxStatus.Failed);
- expect(result.error).toMatch(/Unreadable alert event payload/);
+ expect(result.error).toContain("Unreadable alert event payload");
});
test("runs every matching alert in a scope", async () => {
@@ -151,7 +151,8 @@ describe("alert outbox consumer", () => {
const [result] = await consumer.handle([makeRow({ resourceType: "pki.certificate" })]);
expect(result.status).toBe(EventOutboxStatus.Failed);
- expect(result.error).toMatch(/pki\.certificate.*approval\.workflow\.request_opened/);
+ expect(result.error).toContain("pki.certificate");
+ expect(result.error).toContain("approval.workflow.request_opened");
expect(runs).toHaveLength(0);
expect(getLookups()).toBe(0);
});
diff --git a/backend/src/services/alert/alert-provider-registry.test.ts b/backend/src/services/alert/alert-provider-registry.test.ts
index cd7b6f95bc..daecfdec3f 100644
--- a/backend/src/services/alert/alert-provider-registry.test.ts
+++ b/backend/src/services/alert/alert-provider-registry.test.ts
@@ -21,7 +21,7 @@ describe("alert provider registry", () => {
const registry = alertProviderRegistryFactory();
registry.register(baseProvider({}));
- expect(() => registry.register(baseProvider({}))).toThrow(/already registered/);
+ expect(() => registry.register(baseProvider({}))).toThrow("already registered");
});
// Both guards fail the boot in routes/index.ts, rather than letting a dispatch silently no-op in
@@ -33,7 +33,7 @@ describe("alert provider registry", () => {
registry.register(
baseProvider({ events: [{ key: "test.resource.expiry", triggerType: AlertTriggerType.Scheduled }] })
)
- ).toThrow(/does not implement findDueTargets/);
+ ).toThrow("does not implement findDueTargets");
});
test("rejects an event-triggered event with no findTargetsByIds", () => {
@@ -43,7 +43,7 @@ describe("alert provider registry", () => {
registry.register(
baseProvider({ events: [{ key: "test.resource.opened", triggerType: AlertTriggerType.Event }] })
)
- ).toThrow(/does not implement findTargetsByIds/);
+ ).toThrow("does not implement findTargetsByIds");
});
test("accepts a provider that implements the method each of its events needs", () => {
diff --git a/backend/src/services/event-outbox/event-outbox-service.test.ts b/backend/src/services/event-outbox/event-outbox-service.test.ts
index f53fc89b61..c3945ae8fb 100644
--- a/backend/src/services/event-outbox/event-outbox-service.test.ts
+++ b/backend/src/services/event-outbox/event-outbox-service.test.ts
@@ -6,6 +6,7 @@ import {
EventOutboxStatus,
IEventOutboxConsumer,
MAX_OUTBOX_ATTEMPTS,
+ MAX_OUTBOX_PAYLOAD_BYTES,
TEventOutboxRow,
TOutboxEvent
} from "./event-outbox-types";
@@ -94,7 +95,7 @@ describe("event outbox emit", () => {
const { service, inserted } = buildService([makeConsumer()]);
await expect(service.emit(makeEvent({ payload: { targetIds: [] } }), TX)).rejects.toThrow(
- /the 'alert' consumer cannot accept/
+ "the 'alert' consumer cannot accept"
);
expect(inserted).toHaveLength(0);
});
@@ -105,7 +106,7 @@ describe("event outbox emit", () => {
]);
await expect(service.emit(makeEvent({ payload: { blob: "x".repeat(20_000) } }), TX)).rejects.toThrow(
- /over the .* byte limit/
+ `over the ${MAX_OUTBOX_PAYLOAD_BYTES} byte limit`
);
expect(inserted).toHaveLength(0);
});
@@ -113,7 +114,7 @@ describe("event outbox emit", () => {
test("throws on a malformed event envelope", async () => {
const { service } = buildService([makeConsumer()]);
- await expect(service.emit(makeEvent({ orgId: "not-a-uuid" }), TX)).rejects.toThrow(/Invalid outbox event/);
+ await expect(service.emit(makeEvent({ orgId: "not-a-uuid" }), TX)).rejects.toThrow("Invalid outbox event");
});
// Swallowing it would hand the caller a poisoned transaction instead of the real error.
diff --git a/backend/src/services/event-outbox/event-outbox-types.ts b/backend/src/services/event-outbox/event-outbox-types.ts
index fe5b46f26f..193fa1f816 100644
--- a/backend/src/services/event-outbox/event-outbox-types.ts
+++ b/backend/src/services/event-outbox/event-outbox-types.ts
@@ -1,3 +1,4 @@
+import RE2 from "re2";
import { z } from "zod";
import { TEventOutbox } from "@app/db/schemas";
@@ -43,7 +44,10 @@ const keySchema = z
.trim()
.min(1)
.max(MAX_OUTBOX_KEY_LENGTH)
- .regex(/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/, "Must be lowercase and dot-namespaced, e.g. 'pki.certificate.issued'");
+ .regex(
+ new RE2(/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/),
+ "Must be lowercase and dot-namespaced, e.g. 'pki.certificate.issued'"
+ );
export const OutboxEventSchema = z.object({
eventType: keySchema,