{"record":{"id":"99c77a23746c451f","repo":"n8n-io/n8n","slug":"filter-operator-operator-on-key-key-requ-99c77a","errorCode":null,"errorMessage":"Filter operator \"${operator}\" on key \"${key}\" requires array elements to be strings or numbers.","messagePattern":"Filter operator \"(.+?)\" on key \"(.+?)\" requires array elements to be strings or numbers\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/agents/src/sdk/vector-store-filter.ts","lineNumber":55,"sourceCode":"}\n\nfunction assertValidCondition(condition: FilterCondition): void {\n\tconst { key, operator, value } = condition;\n\n\tif (!(FILTER_OPERATORS as readonly string[]).includes(operator)) {\n\t\tthrow new Error(\n\t\t\t`Invalid filter operator \"${operator}\" for key \"${key}\". Supported operators: ${FILTER_OPERATORS.join(', ')}`,\n\t\t);\n\t}\n\n\tif (operator === 'in' || operator === 'nin') {\n\t\tif (!Array.isArray(value) || value.length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Filter operator \"${operator}\" on key \"${key}\" requires a non-empty array value.`,\n\t\t\t);\n\t\t}\n\t\tif (value.some((v) => typeof v !== 'string' && typeof v !== 'number')) {\n\t\t\tthrow new Error(\n\t\t\t\t`Filter operator \"${operator}\" on key \"${key}\" requires array elements to be strings or numbers.`,\n\t\t\t);\n\t\t}\n\t\treturn;\n\t}\n\n\t// eq, ne\n\tif (typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean') {\n\t\tthrow new Error(\n\t\t\t`Filter operator \"${operator}\" on key \"${key}\" requires a string, number, or boolean value.`,\n\t\t);\n\t}\n}\n\nfunction isNonEmptyArray(arr: string[]): arr is [string, ...string[]] {\n\treturn arr.length > 0;\n}\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/agents/src/sdk/vector-store-filter.ts#L37-L73","documentation":"For 'in' and 'nin' operators, after confirming the value is a non-empty array, assertValidCondition checks every element is a string or number. Mixed-type or object/null elements are rejected because vector store metadata indexes are scalar-typed; allowing them would produce backend-specific coercion or query failures. The check is per-element via Array.some.","triggerScenarios":"Calling search with filter: { conditions: [{ key: 'tag', operator: 'in', value: ['x', null] }] } or value: [{ id: 1 }, { id: 2 }] (objects) or value: [true, false] (booleans not allowed in arrays).","commonSituations":"Passing an array of objects when only their id field matters; mixed types from loose user input; booleans or nulls leaking in from a form; serializing Date objects directly instead of as ISO strings.","solutions":["Map array elements to strings or numbers before building the condition: value: items.map(i => i.id).","Filter out null/undefined/object elements before constructing the filter.","Serialize Dates to ISO strings (value.toISOString()) and other complex types to a string/number key."],"exampleFix":"// before\nstore.search('q', {\n  filter: { conditions: [{ key: 'cat', operator: 'in', value: items }], combineWith: 'and' },\n}); // items are objects — throws\n\n// after\nstore.search('q', {\n  filter: { conditions: [{ key: 'cat', operator: 'in', value: items.map(i => i.id) }], combineWith: 'and' },\n});","handlingStrategy":"type-guard","validationCode":"function inCondition(key: string, values: unknown[]) {\n  if (!values.every(v => typeof v === 'string' || typeof v === 'number')) {\n    throw new Error(`'in' filter on ${key} requires string/number elements`);\n  }\n  return { key, operator: 'in' as const, value: values };\n}","typeGuard":"function isScalarArray(v: unknown): v is (string | number)[] {\n  return Array.isArray(v) && v.every(x => typeof x === 'string' || typeof x === 'number');\n}","tryCatchPattern":null,"preventionTips":["Map object elements to their scalar id field before building 'in' conditions.","Filter out null/undefined/object elements at the source.","Serialize Dates and complex types to strings before they reach the filter builder."],"tags":["vector-store","filter","validation","type-mismatch","array"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}