{"record":{"id":"249dbe7c30b6e6f8","repo":"mem0ai/mem0","slug":"oracle-filter-operator-operator-requires-scal","errorCode":null,"errorMessage":"Oracle filter operator '${operator}' requires scalar values","messagePattern":"Oracle filter operator '(.+?)' requires scalar values","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/oracledb.ts","lineNumber":198,"sourceCode":"      }\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);\n        listPassings.push(passing);\n      }\n\n      const membership = jsonExists(\n        path,\n        `@ in (${variables.join(\", \")})`,\n        listPassings,\n      );\n      additionalClauses.push(","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/oracledb.ts#L180-L216","documentation":"Each element of an in/nin array is bound as an individual scalar bind variable in the JSON_EXISTS PASSING clause. Nested objects, arrays, or other non-scalar elements cannot be bound, so any non-scalar item is rejected.","triggerScenarios":"{ items: { in: [['a','b'], 'c'] } } (nested array), { refs: { in: [{ id: 1 }, { id: 2 }] } } (objects), or a list produced by map() that accidentally returns objects instead of primitive field values.","commonSituations":"Forgetting to extract a field: users.map(u => u) instead of users.map(u => u.id); JSON-parsed payloads containing mixed shapes; mixing null (allowed) with objects (not allowed) in one list.","solutions":["Map the list to primitives before filtering: ids.map(u => u.id).","Flatten nested arrays or use OR-groups of contains filters for nested matching.","Filter out non-scalar entries: list.filter(v => v === null || ['string','number','boolean'].includes(typeof v)).","Validate list shape in one place (a shared filter sanitizer) before calling search()."],"exampleFix":"// before\nfilters = { user_id: { in: users } }; // array of objects\n\n// after\nfilters = { user_id: { in: users.map((u) => u.id) } };","handlingStrategy":"validation","validationCode":"const isScalar = (v: unknown) => v === null || ['string','number','boolean'].includes(typeof v);\nfunction assertScalarList(field: string, op: string, list: unknown[]): void {\n  const bad = list.filter((v) => !isScalar(v));\n  if (bad.length) throw new TypeError(`${field}.${op} contains non-scalar items: ${JSON.stringify(bad[0])}`);\n}","typeGuard":"const isScalarList = (v: unknown): v is (string | number | boolean | null)[] =>\n  Array.isArray(v) && v.every((x) => x === null || ['string','number','boolean'].includes(typeof x));","tryCatchPattern":"try { await memory.search('q', { filters }); } catch (e) { if (e instanceof Error && e.message.includes('requires scalar values')) { /* map list items to primitives (e.g. x.id) and retry */ } else throw e; }","preventionTips":["Map object lists to a key before using them in in/nin.","Flatten or reject nested arrays at the API boundary.","Write one shared list-sanitizer used by all filter builders."],"tags":["oracle","filters","arrays","validation","scalar"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}