{"record":{"id":"457fa64e15da5fff","repo":"mem0ai/mem0","slug":"or-filter-value-must-be-a-list-of-filter-dicts-go-457fa6","errorCode":null,"errorMessage":"OR filter value must be a list of filter dicts, got ${typeof value}","messagePattern":"OR filter value must be a list of filter dicts, got (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/databricks.ts","lineNumber":1596,"sourceCode":"    }\n\n    for (const [key, value] of Object.entries(normalized)) {\n      if (key === \"AND\") {\n        if (!Array.isArray(value)) {\n          throw new Error(\n            `AND filter value must be a list of filter dicts, got ${typeof value}`,\n          );\n        }\n        if (\n          !value.every((entry: SearchFilters) =>\n            this.filterVector(vector, entry),\n          )\n        ) {\n          return false;\n        }\n      } else if (key === \"OR\") {\n        if (!Array.isArray(value)) {\n          throw new Error(\n            `OR filter value must be a list of filter dicts, got ${typeof value}`,\n          );\n        }\n        if (\n          !value.some((entry: SearchFilters) =>\n            this.filterVector(vector, entry),\n          )\n        ) {\n          return false;\n        }\n      } else if (key === \"NOT\") {\n        if (!Array.isArray(value)) {\n          throw new Error(\n            `NOT filter value must be a list of filter dicts, got ${typeof value}`,\n          );\n        }\n        if (\n          !value.every(","sourceCodeStart":1578,"sourceCodeEnd":1614,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/databricks.ts#L1578-L1614","documentation":"filterVector() throws when an OR filter key holds a non-array value. OR branches are evaluated with .some() over a list of sub-filter dicts; anything else (object, string, number) is a malformed filter and is rejected before evaluation rather than treated as a match/no-match.","triggerScenarios":"Calling search()/list() with { OR: { user_id: 'u1' } } or { $or: 'x' } instead of { OR: [{ user_id: 'u1' }, { user_id: 'u2' }] }.","commonSituations":"Hand-written filters copied from SQL intuitions ('OR' as a flat object); dynamic filter assembly that forgets the array wrapper; porting Python SDK examples where nesting differs.","solutions":["Use array form for $or/OR branches: { $or: [{...}, {...}] }.","Add a shared helper that constructs compound filters so the array shape is enforced in one place.","Unit-test filter construction code against the expected shape."],"exampleFix":"// before\nstore.search(query, 5, { OR: { user_id: 'u1' } });\n\n// after\nstore.search(query, 5, { OR: [{ user_id: 'u1' }] });","handlingStrategy":"type-guard","validationCode":"if ('OR' in filters && !Array.isArray((filters as any).OR)) {\n  throw new Error('OR branch must be an array of filter dicts');\n}","typeGuard":"const hasArrayBranches = (f: unknown): f is Record<string, unknown[]> =>\n  typeof f === 'object' && f !== null &&\n  Object.entries(f).every(([k, v]) =>\n    k === 'OR' || k === 'AND' || k === 'NOT' ? Array.isArray(v) : true,\n  );","tryCatchPattern":"try {\n  await store.search(q, k, filters);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('OR filter value must be a list')) {\n    // normalize OR value to an array and retry\n  }\n  throw e;\n}","preventionTips":["Treat $or/OR strictly as a list of sub-filter dicts.","Use a shared typed filter builder instead of inline literals.","Validate dynamically-built filters before passing them to search/list."],"tags":["databricks","filters","validation","vector-store","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}