Skip to content

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

fix: upsert traces on ingestion only on the id (#900)

Max Deichmannf08502cde4a5
diff --git a/src/server/api/services/EventProcessor.ts b/src/server/api/services/EventProcessor.ts
index 630988ff97..ad31d7eb04 100644
--- a/src/server/api/services/EventProcessor.ts
+++ b/src/server/api/services/EventProcessor.ts
@@ -294,6 +294,16 @@ export class TraceProcessor implements EventProcessor {
},
});
+ // access rights note:
+ // if trace exists, check if project id matches
+ // if trace does not exist, insert the trace with the projectId from scope
+
+ if (existingTrace && existingTrace.projectId !== apiScope.projectId) {
+ throw new AuthenticationError(
+ `Access denied for trace creation ${existingTrace.projectId} `,
+ );
+ }
+
const mergedMetadata = mergeJson(
existingTrace?.metadata
? jsonSchema.parse(existingTrace.metadata)
@@ -304,7 +314,6 @@ export class TraceProcessor implements EventProcessor {
const upsertedTrace = await prisma.trace.upsert({
where: {
id: internalId,
- projectId: apiScope.projectId,
},
create: {
id: internalId,