From c4b5dedb77e6b183e0b01c66735bc9dc43b331a8 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Wed, 1 Apr 2026 13:01:02 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=92=20fix:=20Exclude=20Unnecessary=20f?= =?UTF-8?q?ields=20from=20Conversation=20`$unset`=20(#12501)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `BaseClient.js` iterates existing conversation keys to build `unsetFields` for removal when `endpointOptions` doesn't include them. When tenant isolation stamps `tenantId` on the document, it gets swept into `$unset`, triggering `assertNoTenantIdMutation`. Adding `tenantId` to `excludedKeys` prevents this — it's a system field, not an endpoint option. --- packages/data-provider/src/config.spec.ts | 11 ++++++++++- packages/data-provider/src/config.ts | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/data-provider/src/config.spec.ts b/packages/data-provider/src/config.spec.ts index 4197cb754e..d7c81b02bc 100644 --- a/packages/data-provider/src/config.spec.ts +++ b/packages/data-provider/src/config.spec.ts @@ -1,7 +1,7 @@ import type { TEndpointsConfig } from './types'; import { EModelEndpoint, isDocumentSupportedProvider } from './schemas'; import { getEndpointFileConfig, mergeFileConfig } from './file-config'; -import { resolveEndpointType } from './config'; +import { resolveEndpointType, excludedKeys } from './config'; const endpointsConfig: TEndpointsConfig = { [EModelEndpoint.openAI]: { userProvide: false, order: 0 }, @@ -13,6 +13,15 @@ const endpointsConfig: TEndpointsConfig = { Gemini: { type: EModelEndpoint.custom, userProvide: false, order: 9999 }, }; +describe('excludedKeys', () => { + it.each(['_id', 'user', 'conversationId', '__v', 'tenantId'])( + 'excludes system field "%s"', + (field) => { + expect(excludedKeys.has(field)).toBe(true); + }, + ); +}); + describe('resolveEndpointType', () => { describe('non-agents endpoints', () => { it('returns the config type for a custom endpoint', () => { diff --git a/packages/data-provider/src/config.ts b/packages/data-provider/src/config.ts index ae3f5b9560..779885b456 100644 --- a/packages/data-provider/src/config.ts +++ b/packages/data-provider/src/config.ts @@ -48,6 +48,7 @@ export const excludedKeys = new Set([ 'isArchived', 'tags', 'user', + 'tenantId', '__v', '_id', 'tools',