{"record":{"id":"1b4034113daa2cff","repo":"mem0ai/mem0","slug":"unsupported-neptune-analytics-algorithm-value-type","errorCode":null,"errorMessage":"Unsupported Neptune Analytics algorithm value type: ${typeof value}","messagePattern":"Unsupported Neptune Analytics algorithm value type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/neptune_analytics.ts","lineNumber":934,"sourceCode":"\n    if (typeof value === \"string\") {\n      return JSON.stringify(value);\n    }\n\n    if (typeof value === \"number\" || typeof value === \"boolean\") {\n      return String(value);\n    }\n\n    if (typeof value === \"object\") {\n      return `{ ${Object.entries(value)\n        .map(\n          ([key, entry]) =>\n            `${this.serializeAlgorithmKey(key)}: ${this.serializeAlgorithmInput(entry)}`,\n        )\n        .join(\", \")} }`;\n    }\n\n    throw new Error(\n      `Unsupported Neptune Analytics algorithm value type: ${typeof value}`,\n    );\n  }\n\n  private serializeAlgorithmKey(key: string): string {\n    if (/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {\n      return key;\n    }\n\n    return JSON.stringify(key);\n  }\n\n  private assertVectorDimension(vector: number[], context: string): void {\n    if (vector.length !== this.dimension) {\n      throw new Error(\n        `${context} dimension mismatch. Expected ${this.dimension}, got ${vector.length}`,\n      );\n    }","sourceCodeStart":916,"sourceCodeEnd":952,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/neptune_analytics.ts#L916-L952","documentation":"Neptune Analytics algorithm parameters (e.g. knn configuration) are serialized into an openCypher map literal by value type: numbers/booleans/strings directly, plain objects recursively. Any other type — function, symbol, bigint, array at this position — cannot be rendered into the query string, so serialization throws.","triggerScenarios":"Passing an algorithm config containing an array at the top level of a map position, a Date instance, null in an unsupported slot, or a bigint, e.g. config like { knn: { someParam: [1,2] } } where the serializer only handles scalars and objects.","commonSituations":"Hand-writing algorithm configuration copied from AWS console examples that use array syntax; passing runtime-computed values that end up as undefined function results; version changes that altered accepted config shapes.","solutions":["Convert arrays to an object form or string before passing them in algorithm parameters.","Ensure every algorithm parameter value is a string, number, boolean, or a nested plain object of those.","Log typeof for each config value before constructing the store if the error is unclear."],"exampleFix":"// before\nalgorithmParams = { embeddingDimension: 1536, sources: ['s3://bucket'] };\n\n// after\nalgorithmParams = { embeddingDimension: 1536, sources: 's3://bucket' };","handlingStrategy":"type-guard","validationCode":"function assertSerializable(value: unknown): void {\n  const t = typeof value;\n  if (t !== 'string' && t !== 'number' && t !== 'boolean' && t !== 'object') {\n    throw new TypeError(`Algorithm param of type ${t} cannot be serialized`);\n  }\n  if (t === 'object' && value !== null) Object.values(value as object).forEach(assertSerializable);\n}\nassertSerializable(algorithmParams);","typeGuard":"const isPlainSerializable = (v: unknown): boolean => {\n  if (v === null) return true;\n  const t = typeof v;\n  return t === 'string' || t === 'number' || t === 'boolean' || (t === 'object' && !Array.isArray(v) && Object.values(v).every(isPlainSerializable));\n};","tryCatchPattern":null,"preventionTips":["Keep algorithm params to scalars and nested plain objects","Convert arrays to strings or objects first","Unit-test config serialization before store creation"],"tags":["neptune-analytics","algorithm-config","serialization","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}