{"record":{"id":"68dc84a9b097c2f5","repo":"mem0ai/mem0","slug":"oracle-filter-operator-operator-requires-a-no","errorCode":null,"errorMessage":"Oracle filter operator '${operator}' requires a non-empty array","messagePattern":"Oracle filter operator '(.+?)' requires a non-empty array","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/oracledb.ts","lineNumber":189,"sourceCode":"      }\n      if (operand === null) {\n        if (operator !== \"eq\" && operator !== \"ne\") {\n          throw new Error(\n            `Oracle filter operator '${operator}' does not support null`,\n          );\n        }\n        predicates.push(`@ ${COMPARISON_OPERATORS[operator]} null`);\n        continue;\n      }\n      const [variable, passing] = bindFilterValue(operand, binds);\n      predicates.push(`@ ${COMPARISON_OPERATORS[operator]} ${variable}`);\n      passings.push(passing);\n      continue;\n    }\n\n    if (operator === \"in\" || operator === \"nin\") {\n      if (!Array.isArray(operand) || operand.length === 0) {\n        throw new Error(\n          `Oracle filter operator '${operator}' requires a non-empty array`,\n        );\n      }\n\n      const variables: string[] = [];\n      const listPassings: string[] = [];\n      for (const item of operand) {\n        if (!isScalar(item)) {\n          throw new Error(\n            `Oracle filter operator '${operator}' requires scalar values`,\n          );\n        }\n        if (item === null) {\n          variables.push(\"null\");\n          continue;\n        }\n        const [variable, passing] = bindFilterValue(item, binds);\n        variables.push(variable);","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/oracledb.ts#L171-L207","documentation":"The in/nin operators compile to a JSON_EXISTS '@ in (...)' list, which requires at least one element to form valid predicate syntax and a NOT-wrap for nin. Passing a non-array operand or an empty array is rejected up front.","triggerScenarios":"{ status: { in: [] } } (empty array, usually from dynamic list-building), { status: 'active' } where a bare string reaches the operator branch, { ids: { in: 'abc' } } (string instead of array), or { ids: { in: null } }.","commonSituations":"Whitelist/allowlist filters computed at runtime that end up empty (e.g. no user roles matched); passing a comma-separated string instead of an array; a client sending a scalar where the server forwards it as the in-operand.","solutions":["Skip the filter clause entirely when the list is empty rather than sending { in: [] }.","Wrap single values in an array: { status: { in: ['active'] } }.","Split strings into arrays: ids.split(',') before filtering.","For 'match anything' semantics with nin and an empty exclusion list, omit the nin clause instead."],"exampleFix":"// before\nconst filters = statuses.length ? { status: { in: statuses } } : { status: { in: [] } };\n\n// after\nconst filters = statuses.length > 0 ? { status: { in: statuses } } : undefined;\nawait memory.search('q', { filters });","handlingStrategy":"validation","validationCode":"function sanitizeInFilters(filters: any): any {\n  if (Array.isArray(filters)) return filters.map(sanitizeInFilters);\n  if (!filters || typeof filters !== 'object') return filters;\n  const out: Record<string, any> = {};\n  for (const [k, v] of Object.entries(filters)) {\n    if (v && typeof v === 'object' && ('in' in v || 'nin' in v)) {\n      const cleaned: Record<string, any> = {};\n      for (const [op, list] of Object.entries(v)) {\n        if ((op === 'in' || op === 'nin') && (!Array.isArray(list) || list.length === 0)) continue; // drop empty/invalid\n        cleaned[op] = list;\n      }\n      if (Object.keys(cleaned).length) out[k] = cleaned;\n    } else out[k] = v;\n  }\n  return Object.keys(out).length ? out : undefined;\n}","typeGuard":"const isNonEmptyArray = (v: unknown): v is unknown[] => Array.isArray(v) && v.length > 0;","tryCatchPattern":null,"preventionTips":["Only include in/nin clauses when the list has at least one element.","Wrap scalars into one-element arrays before passing to in.","Treat empty allowlists as 'no filter', not { in: [] }."],"tags":["oracle","filters","arrays","validation"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}