{"record":{"id":"751fdc57ac53bd74","repo":"supermemoryai/supermemory","slug":"customid-is-required-provide-a-non-empty-string","errorCode":null,"errorMessage":"customId is required — provide a non-empty string to group messages into a single document","messagePattern":"customId is required — provide a non-empty string to group messages into a single document","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tools/src/openai/index.ts","lineNumber":77,"sourceCode":" * ```\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,\n\t\t{\n\t\t\t...options,\n\t\t\tverbose,\n\t\t\tmode,\n\t\t\taddMemory,\n\t\t},","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/supermemoryai/supermemory/blob/d436792e777a99865939dd543c8d1a16d57f54ec/packages/tools/src/openai/index.ts#L59-L95","documentation":"The OpenAI middleware's withSupermemory requires options.customId, which groups the messages of one conversation into a single Supermemory document. Without it the middleware cannot decide which document a chat belongs to.","triggerScenarios":"Calling withSupermemory with customId omitted, empty, or undefined (e.g. generated per-request but occasionally falsy).","commonSituations":"Reusing old examples that only passed containerTag; computing customId from an optional query param that is missing; typo like customID.","solutions":["Pass a stable non-empty customId per conversation/session","Generate one (e.g. crypto.randomUUID()) at conversation start if you don't have a natural id","Validate options before wiring the middleware at app startup"],"exampleFix":"// before\nwithSupermemory(openai, { containerTag: 'user-1' })\n\n// after\nwithSupermemory(openai, { containerTag: 'user-1', customId: conversationId })","handlingStrategy":"validation","validationCode":"if (!options?.customId) throw new TypeError('customId required')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Assign a conversation id at conversation start and thread it through","Type options as Required<Pick<..., 'customId'>> in your own wrappers"],"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"}