Skip to content

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

test(topics): cover first-run setup project isolation (#19643)

Lysander Kieselff13c20f564b
diff --git a/web/src/__tests__/server/topics-trpc-access.servertest.ts b/web/src/__tests__/server/topics-trpc-access.servertest.ts
index be1bd8ecb7..ed7a815e9b 100644
--- a/web/src/__tests__/server/topics-trpc-access.servertest.ts
+++ b/web/src/__tests__/server/topics-trpc-access.servertest.ts
@@ -249,6 +249,14 @@ describe("Topics tRPC access", () => {
embeddingConfig: topicEmbeddingConfigSchema.parse({}),
}),
).rejects.toThrow("Facet version not found in this project.");
+ await expect(
+ admin.startSetup({
+ projectId,
+ requestId: randomUUID(),
+ sampling: 1,
+ facets: [{ facetId: b.facetId, version: 1 }],
+ }),
+ ).rejects.toThrow("Facet version not found in this project.");
// Project B is untouched.
expect(
@@ -263,6 +271,27 @@ describe("Topics tRPC access", () => {
).toBe(0);
});
+ it("rejects first-run setup reads and writes for a project the caller is not a member of", async () => {
+ const memberOfA = caller(userId, [[a.orgId, a.projectId, "ADMIN"]]);
+
+ // Positive control: the caller's own project answers.
+ await expect(
+ memberOfA.setupTraceCounts({ projectId: a.projectId }),
+ ).resolves.toBeDefined();
+
+ await expect(
+ memberOfA.setupTraceCounts({ projectId: b.projectId }),
+ ).rejects.toMatchObject({ code: "UNAUTHORIZED" });
+ await expect(
+ memberOfA.startSetup({
+ projectId: b.projectId,
+ requestId: randomUUID(),
+ sampling: 1,
+ facets: [{ facetId: b.facetId, version: 1 }],
+ }),
+ ).rejects.toMatchObject({ code: "UNAUTHORIZED" });
+ });
+
it("resolves LLM connections by provider within the project, then its organization", async () => {
const admin = caller(userId, [
[a.orgId, a.projectId, "ADMIN"],