{"record":{"id":"fdaa0588f76e9120","repo":"n8n-io/n8n","slug":"invalid-filter-operator-operator-for-key-k","errorCode":null,"errorMessage":"Invalid filter operator \"${operator}\" for key \"${key}\". Supported operators: ${FILTER_OPERATORS.join(', ')}","messagePattern":"Invalid filter operator \"(.+?)\" for key \"(.+?)\"\\. Supported operators: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/agents/src/sdk/vector-store-filter.ts","lineNumber":43,"sourceCode":"\t\tkey,\n\t\toperator: 'eq',\n\t\tvalue,\n\t}));\n\treturn { conditions, combineWith: 'and' };\n}\n\n/** Validates operator/value pairing per condition; throws rather than silently ignoring a bad filter. */\nexport function assertValidFilter(filter: VectorFilter): void {\n\tfor (const condition of filter.conditions) {\n\t\tassertValidCondition(condition);\n\t}\n}\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","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/agents/src/sdk/vector-store-filter.ts#L25-L61","documentation":"assertValidCondition rejects any filter condition whose operator is not in FILTER_OPERATORS (eq, ne, in, nin). The validator runs on every condition in a VectorFilter before the search backend sees it, so unsupported operators never reach the vector store — they fail loudly instead of silently behaving as eq or being dropped.","triggerScenarios":"Calling vectorStore.search(query, { filter: { conditions: [{ key: 'tag', operator: 'contains', value: 'x' }], combineWith: 'and' } }) or the shorthand { tag: 'x' } (always eq, safe) with an operator typo like 'equal', 'not_equal', 'within'. Also hit by constructing a VectorFilter programmatically with a string not in the allowed set.","commonSituations":"Translating filter syntax from another query language (SQL LIKE, Mongo $eq, Pinecone semantics) into this API's operator vocabulary; typos; building filters from user input without restricting the operator set.","solutions":["Use only supported operators: 'eq', 'ne', 'in', 'nin'.","For substring/contains needs, filter post-query client-side since the backend only supports equality/set membership.","When building filters from user input, validate the operator against FILTER_OPERATORS (exported) before constructing the condition."],"exampleFix":"// before\nstore.search('q', {\n  filter: { conditions: [{ key: 'tag', operator: 'contains', value: 'x' }], combineWith: 'and' },\n}); // throws\n\n// after\nstore.search('q', {\n  filter: { conditions: [{ key: 'tag', operator: 'eq', value: 'x' }], combineWith: 'and' },\n});","handlingStrategy":"validation","validationCode":"import { FILTER_OPERATORS } from '@n8n/agents/sdk/vector-store-filter';\n\nfunction buildCondition(key: string, operator: string, value: unknown) {\n  if (!(FILTER_OPERATORS as readonly string[]).includes(operator)) {\n    throw new Error(`Unsupported operator ${operator}. Use one of: ${FILTER_OPERATORS.join(', ')}`);\n  }\n  return { key, operator, value } as const;\n}","typeGuard":"import { FILTER_OPERATORS } from '@n8n/agents/sdk/vector-store-filter';\nfunction isValidFilterOperator(op: unknown): op is typeof FILTER_OPERATORS[number] {\n  return typeof op === 'string' && (FILTER_OPERATORS as readonly string[]).includes(op);\n}","tryCatchPattern":null,"preventionTips":["Restrict the operator set at the UI/API boundary so users cannot submit unknown operators.","Map foreign query syntax (SQL, Mongo) to the four supported operators explicitly.","Reuse the exported FILTER_OPERATORS constant for any allow-list check."],"tags":["vector-store","filter","validation","configuration"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}