🔒 fix: Exclude Unnecessary fields from Conversation $unset (#12501)
Some checks are pending
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Waiting to run
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Waiting to run

`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.
This commit is contained in:
Danny Avila 2026-04-01 13:01:02 -04:00 committed by GitHub
parent 5e789f589f
commit c4b5dedb77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View file

@ -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', () => {

View file

@ -48,6 +48,7 @@ export const excludedKeys = new Set([
'isArchived',
'tags',
'user',
'tenantId',
'__v',
'_id',
'tools',