diff --git a/packages/server/src/api/controllers/automation.ts b/packages/server/src/api/controllers/automation.ts index bceebf39b7..937b052d9c 100644 --- a/packages/server/src/api/controllers/automation.ts +++ b/packages/server/src/api/controllers/automation.ts @@ -75,7 +75,8 @@ export async function update(ctx: UserCtx) { } export async function fetch(ctx: UserCtx) { - const enrich = ctx.request.query["enrich"] === "true" + const query = ctx.request.query || {} + const enrich = query["enrich"] === "true" const automations = await sdk.automations.fetch() ctx.body = { automations } diff --git a/packages/server/src/api/routes/tests/automation.spec.ts b/packages/server/src/api/routes/tests/automation.spec.ts index 98d38f4973..f0c3d6e1c5 100644 --- a/packages/server/src/api/routes/tests/automation.spec.ts +++ b/packages/server/src/api/routes/tests/automation.spec.ts @@ -398,7 +398,9 @@ describe("/automations", () => { .expect("Content-Type", /json/) .expect(200) - expect(res.body[0]).toEqual(expect.objectContaining(autoConfig)) + expect(res.body.automations[0]).toEqual( + expect.objectContaining(autoConfig) + ) }) it("should apply authorization to endpoint", async () => {