{"record":{"id":"517756e10b88b6fe","repo":"supermemoryai/supermemory","slug":"containertag-is-required-provide-a-non-empty-str","errorCode":null,"errorMessage":"containerTag is required — provide a non-empty string to identify the user/container","messagePattern":"containerTag is required — provide a non-empty string to identify the user/container","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tools/src/openai/index.ts","lineNumber":71,"sourceCode":" * // Use with Responses API - memories injected into instructions\n * const response = await openaiWithSupermemory.responses.create({\n *   model: \"gpt-4o\",\n *   instructions: \"You are a helpful coding assistant\",\n *   input: \"What's my favorite programming language?\"\n * })\n * ```\n *\n * @throws {Error} When neither `options.apiKey` nor `process.env.SUPERMEMORY_API_KEY` are set\n * @throws {Error} When supermemory API request fails\n */\nexport function withSupermemory(\n\topenaiClient: OpenAI,\n\toptions: OpenAIMiddlewareOptions,\n) {\n\tvalidateApiKey(options.apiKey)\n\n\tif (!options.containerTag) {\n\t\tthrow new Error(\n\t\t\t\"containerTag is required — provide a non-empty string to identify the user/container\",\n\t\t)\n\t}\n\n\tif (!options.customId) {\n\t\tthrow new Error(\n\t\t\t\"customId is required — provide a non-empty string to group messages into a single document\",\n\t\t)\n\t}\n\n\tconst { containerTag } = options\n\tconst verbose = options.verbose ?? false\n\tconst mode = options.mode ?? \"profile\"\n\tconst addMemory = options.addMemory ?? \"always\"\n\n\tconst openaiWithSupermemory = createOpenAIMiddleware(\n\t\topenaiClient,\n\t\tcontainerTag,","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/supermemoryai/supermemory/blob/d436792e777a99865939dd543c8d1a16d57f54ec/packages/tools/src/openai/index.ts#L53-L89","documentation":"The OpenAI middleware's withSupermemory requires options.containerTag because memories are scoped per user/container on Supermemory's side. An empty/missing containerTag means the middleware cannot attribute conversations to a user.","triggerScenarios":"Calling withSupermemory(openai, { customId, apiKey }) without containerTag, or passing containerTag: '' / undefined.","commonSituations":"Copy-pasting a minimal example that omitted containerTag; dynamically computing containerTag from user data that is sometimes empty.","solutions":["Provide a non-empty containerTag identifying the user/tenant, e.g. 'user-<id>' or 'org-<id>'","Derive containerTag from your auth session so it is never empty","Add a startup assertion validating all required options"],"exampleFix":"// before\nwithSupermemory(openai, { customId: 'chat-1', apiKey })\n\n// after\nwithSupermemory(openai, {\n  containerTag: `user-${session.userId}`,\n  customId: 'chat-1',\n  apiKey,\n})","handlingStrategy":"validation","validationCode":"if (!options?.containerTag) throw new TypeError('containerTag required')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive containerTag from authenticated user id so it's always present","Validate middleware options once at app startup"],"tags":["validation","openai","middleware","supermemory"],"backgroundTag":"missing-required-option","analyzedSha":"d436792e777a99865939dd543c8d1a16d57f54ec","analyzedAt":"2026-08-28T18:04:46.947Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}