From bc6eb73d4371176f99bc8ee2c80f5130fc684ab3 Mon Sep 17 00:00:00 2001 From: Gautam Sharma <148205237+GautamSharma99@users.noreply.github.com> Date: Sat, 11 Jul 2026 07:45:25 +0530 Subject: [PATCH] fix(tools): reject conflicting container config (#1214) --- packages/tools/src/tools-shared.test.ts | 28 +++++++++++++++++++++++++ packages/tools/src/tools-shared.ts | 5 +++++ 2 files changed, 33 insertions(+) create mode 100644 packages/tools/src/tools-shared.test.ts diff --git a/packages/tools/src/tools-shared.test.ts b/packages/tools/src/tools-shared.test.ts new file mode 100644 index 00000000..319df6eb --- /dev/null +++ b/packages/tools/src/tools-shared.test.ts @@ -0,0 +1,28 @@ +import { describe, expect, it } from "vitest" +import { getContainerTags } from "./tools-shared" + +describe("getContainerTags", () => { + it("uses the default project when no config is provided", () => { + expect(getContainerTags()).toEqual(["sm_project_default"]) + }) + + it("converts projectId into a project container tag", () => { + expect(getContainerTags({ projectId: "abc" })).toEqual(["sm_project_abc"]) + }) + + it("uses explicit container tags", () => { + expect(getContainerTags({ containerTags: ["tag-a", "tag-b"] })).toEqual([ + "tag-a", + "tag-b", + ]) + }) + + it("rejects config with both projectId and containerTags", () => { + expect(() => + getContainerTags({ + projectId: "abc", + containerTags: ["tag-a"], + }), + ).toThrow("either projectId or containerTags") + }) +}) diff --git a/packages/tools/src/tools-shared.ts b/packages/tools/src/tools-shared.ts index 537b81bd..4b4a5b94 100644 --- a/packages/tools/src/tools-shared.ts +++ b/packages/tools/src/tools-shared.ts @@ -61,6 +61,11 @@ export function getContainerTags(config?: { projectId?: string containerTags?: string[] }): string[] { + if (config?.projectId !== undefined && config.containerTags !== undefined) { + throw new Error( + "Supermemory tools config accepts either projectId or containerTags, not both.", + ) + } if (config?.projectId) { return [`${CONTAINER_TAG_CONSTANTS.projectPrefix}${config.projectId}`] }