fix(tools): reject conflicting container config (#1214)

This commit is contained in:
Gautam Sharma 2026-07-11 07:45:25 +05:30 committed by GitHub
parent 09e3b78fc2
commit bc6eb73d43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 0 deletions

View file

@ -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")
})
})

View file

@ -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}`]
}