{"record":{"id":"1c724e802e34b721","repo":"n8n-io/n8n","slug":"filter-operator-operator-on-key-key-requ-1c724e","errorCode":null,"errorMessage":"Filter operator \"${operator}\" on key \"${key}\" requires a non-empty array value.","messagePattern":"Filter operator \"(.+?)\" on key \"(.+?)\" requires a non-empty array value\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/@n8n/agents/src/vector-stores/pinecone.ts","lineNumber":219,"sourceCode":"\t\t\treturn { $or: [{ [key]: { $ne: value } }, { [key]: { $exists: false } }] };\n\t\tcase 'in':\n\t\t\tassertNonEmptyArray(operator, key, value);\n\t\t\treturn { [key]: { $in: value } };\n\t\tcase 'nin':\n\t\t\tassertNonEmptyArray(operator, key, value);\n\t\t\treturn { $or: [{ [key]: { $nin: value } }, { [key]: { $exists: false } }] };\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported filter operator: \"${String(operator)}\"`);\n\t}\n}\n\nfunction assertNonEmptyArray(\n\toperator: string,\n\tkey: string,\n\tvalue: unknown,\n): asserts value is Array<string | number> {\n\tif (!Array.isArray(value) || value.length === 0) {\n\t\tthrow new Error(\n\t\t\t`Filter operator \"${operator}\" on key \"${key}\" requires a non-empty array value.`,\n\t\t);\n\t}\n}\n","sourceCodeStart":201,"sourceCodeEnd":224,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/agents/src/vector-stores/pinecone.ts#L201-L224","documentation":"Thrown by assertNonEmptyArray in the Pinecone backend when an `in` or `nin` filter condition has a value that is not an array or is an empty array. An empty `$in`/`$nin` is either a no-op or unsatisfiable, so the backend rejects it before building the Pinecone filter. The operator and key are named in the message.","triggerScenarios":"Calling search with `{ filter: { conditions: [{ key: 'topic', operator: 'in', value: [] }] } }`; passing `value: undefined` or a scalar to an `in` condition; building a filter from a list that was filtered down to nothing.","commonSituations":"User selects zero filter values in a UI but the filter is still sent; a query builder that defaults to `[]`; deduplication/removal leaving an empty candidate list; programmatically building conditions without checking length.","solutions":["Omit the `in`/`nin` condition entirely when the candidate list is empty (drop the condition from `conditions`).","Guard filter construction: only push an `in` condition when `values.length > 0`.","If the whole filter becomes empty, pass no filter so the store does an unfiltered query."],"exampleFix":"// before\nawait store.search('q', {\n  filter: { conditions: [{ key: 'topic', operator: 'in', value: [] }] },\n});\n\n// after — only add the condition when non-empty\nconst conditions = [];\nif (topics.length > 0) {\n  conditions.push({ key: 'topic', operator: 'in', value: topics });\n}\nawait store.search('q',\n  conditions.length ? { filter: { conditions, combineWith: 'and' } } : undefined,\n);","handlingStrategy":"validation","validationCode":"function dropEmptyInConditions(filter: VectorFilter): VectorFilter | undefined {\n  const conditions = filter.conditions.filter(\n    (c) => !(c.operator === 'in' || c.operator === 'nin') || (Array.isArray(c.value) && c.value.length > 0),\n  );\n  return conditions.length > 0 ? { ...filter, conditions } : undefined;\n}\n\nconst f = dropEmptyInConditions(inputFilter);\nawait store.search('q', f ? { filter: f } : undefined);","typeGuard":"function isInCondition(c: FilterCondition): c is FilterCondition & { operator: 'in' | 'nin'; value: (string | number)[] } {\n  return (c.operator === 'in' || c.operator === 'nin') && Array.isArray(c.value) && c.value.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Never push an `in`/`nin` condition unless the candidate array is non-empty.","After building conditions, filter out empty-array in/nin entries before passing the filter.","Treat 'all options cleared' in a UI as 'no filter', not 'empty in'."],"tags":["pinecone","filter","validation","vector-store"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}