Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix: fail gracefully for batch actions in case eval config does not exist (#6809)

Max Deichmannd0eeb44b906f
diff --git a/worker/src/__tests__/batchAction.test.ts b/worker/src/__tests__/batchAction.test.ts
index 59e3a2e444..ac06e65cd7 100644
--- a/worker/src/__tests__/batchAction.test.ts
+++ b/worker/src/__tests__/batchAction.test.ts
@@ -452,4 +452,54 @@ describe("select all test suite", () => {
}
});
});
+
+ it("should not create evals if config does not exist", async () => {
+ const { projectId } = await createOrgProjectAndApiKey();
+
+ // Create a trace
+ const traceId = randomUUID();
+ await createTracesCh([
+ createTrace({
+ project_id: projectId,
+ id: traceId,
+ timestamp: new Date("2024-01-01").getTime(),
+ }),
+ ]);
+
+ // Use a non-existent config ID
+ const nonExistentConfigId = randomUUID();
+
+ const queue = getQueue(QueueName.CreateEvalQueue);
+ // Clear any existing jobs
+ await queue?.obliterate({ force: true });
+
+ const payload = {
+ id: randomUUID(),
+ timestamp: new Date(),
+ name: QueueJobs.BatchActionProcessingJob as const,
+ payload: {
+ projectId,
+ actionId: "eval-create" as const,
+ targetObject: "trace" as const,
+ configId: nonExistentConfigId,
+ cutoffCreatedAt: new Date(),
+ query: {
+ filter: [],
+ orderBy: {
+ column: "timestamp",
+ order: "DESC" as const,
+ },
+ },
+ },
+ };
+
+ // This should not throw
+ await expect(handleBatchActionJob(payload)).resolves.not.toThrow();
+
+ // Verify no jobs were created
+ await waitForExpect(async () => {
+ const jobs = await queue?.getJobs();
+ expect(jobs).toHaveLength(0);
+ });
+ });
});
diff --git a/worker/src/features/batchAction/handleBatchActionJob.ts b/worker/src/features/batchAction/handleBatchActionJob.ts
index 748ab62b74..0438c6e9aa 100644
--- a/worker/src/features/batchAction/handleBatchActionJob.ts
+++ b/worker/src/features/batchAction/handleBatchActionJob.ts
@@ -184,7 +184,10 @@ export const handleBatchActionJob = async (
});
if (!config) {
- throw new Error("Eval config not found");
+ logger.error(
+ `Eval config ${configId} not found for project ${projectId}`,
+ );
+ return;
}
const dbReadStream = await getDatabaseReadStream({