{"record":{"id":"8638943425aa4eb0","repo":"mem0ai/mem0","slug":"unsupported-oracle-logical-filter-operator-key","errorCode":null,"errorMessage":"Unsupported Oracle logical filter operator: ${key}","messagePattern":"Unsupported Oracle logical filter operator: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/oracledb.ts","lineNumber":279,"sourceCode":"        throw new Error(\n          `Logical filter operator '${key}' requires a non-empty array`,\n        );\n      }\n      const nested = value.map((condition) =>\n        buildFilterGroup(condition, binds),\n      );\n      if (logicalOperator === \"not\") {\n        clauses.push(`NOT (${nested.join(\" OR \")})`);\n      } else {\n        clauses.push(\n          `(${nested.join(logicalOperator === \"and\" ? \" AND \" : \" OR \")})`,\n        );\n      }\n      continue;\n    }\n\n    if (key.startsWith(\"$\")) {\n      throw new Error(`Unsupported Oracle logical filter operator: ${key}`);\n    }\n\n    clauses.push(buildFieldCondition(key, value, binds));\n  }\n\n  return clauses.length === 1 ? clauses[0] : `(${clauses.join(\" AND \")})`;\n}\n\nexport function buildWhereClause(\n  filters?: SearchFilters,\n): [string, Record<string, any>] {\n  if (!filters || Object.keys(filters).length === 0) {\n    return [\"\", {}];\n  }\n  const binds: Record<string, any> = {};\n  return [`WHERE ${buildFilterGroup(filters, binds)}`, binds];\n}\n","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/oracledb.ts#L261-L297","documentation":"Any key starting with '$' that is not one of the recognized logical operators ($and, $or, $not) is rejected. LOGICAL_OPERATORS also accepts the uppercase forms AND/OR/NOT, but every other dollar-prefixed key at group level is unsupported and would otherwise be misinterpreted as a metadata field name.","triggerScenarios":"{ $nor: [...] }, { $expr: ... } at group level, or nesting errors like { user_id: { $and: [...] } } where $and appears as a field operator — in that position $and is not in FIELD_OPERATORS and surfaces via error 260 instead; group-level $nor/$where/$expr hit this error directly.","commonSituations":"Copying MongoDB query syntax ($nor, $expr, $jsonSchema) into search filters; putting logical operators one level too deep under a field key; mixing filter dialects between mem0 backends.","solutions":["Rewrite $nor as { $not: [...conditions ] } (NOT over the OR-join).","Move logical operators to the group level: { $or: [{ a: 1 }, { b: 2 }] }, never nested inside a field's operator object.","Remove MongoDB-only operators ($expr, $where, $jsonSchema) — express them with supported comparisons or filter client-side.","Check for typos: $AND/$OR (mixed case) are not recognized; use $and/$or or AND/OR."],"exampleFix":"// before\nfilters = { $nor: [{ a: 1 }, { b: 2 }] };\n\n// after\nfilters = { $not: [{ a: 1 }, { b: 2 }] }; // NOT (a==1 OR b==2)","handlingStrategy":"validation","validationCode":"const LOGICAL = new Set(['$and','$or','$not','AND','OR','NOT']);\nfunction assertKnownLogicalKeys(filters: any): void {\n  if (!filters || typeof filters !== 'object') return;\n  for (const key of Object.keys(filters)) {\n    if (key.startsWith('$') && !LOGICAL.has(key)) throw new RangeError(`Unsupported logical operator '${key}'`);\n    const v = (filters as any)[key];\n    if (Array.isArray(v)) v.forEach(assertKnownLogicalKeys);\n  }\n}","typeGuard":"const isSupportedLogicalOperator = (k: string): k is '$and' | '$or' | '$not' | 'AND' | 'OR' | 'NOT' =>\n  ['$and','$or','$not','AND','OR','NOT'].includes(k);","tryCatchPattern":"try { await memory.search('q', { filters }); } catch (e) { if (e instanceof Error && e.message.includes('Unsupported Oracle logical filter operator')) { /* rewrite $nor→$not(...), drop $expr, or filter client-side */ } else throw e; }","preventionTips":["Rewrite $nor as { $not: [...] } when porting Mongo queries.","Keep logical operators at group level only, never under a field key.","Validate filter JSON against a whitelist of keys at the API boundary."],"tags":["oracle","filters","logical-operators","validation"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}