mem0ai/mem0 · error · Error

Unsupported Neptune Analytics algorithm value type: ${typeof

Error message

Unsupported Neptune Analytics algorithm value type: ${typeof value}

What it means

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.

Source

Thrown at mem0-ts/src/oss/src/vector_stores/neptune_analytics.ts:934

    if (typeof value === "string") {
      return JSON.stringify(value);
    }

    if (typeof value === "number" || typeof value === "boolean") {
      return String(value);
    }

    if (typeof value === "object") {
      return `{ ${Object.entries(value)
        .map(
          ([key, entry]) =>
            `${this.serializeAlgorithmKey(key)}: ${this.serializeAlgorithmInput(entry)}`,
        )
        .join(", ")} }`;
    }

    throw new Error(
      `Unsupported Neptune Analytics algorithm value type: ${typeof value}`,
    );
  }

  private serializeAlgorithmKey(key: string): string {
    if (/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {
      return key;
    }

    return JSON.stringify(key);
  }

  private assertVectorDimension(vector: number[], context: string): void {
    if (vector.length !== this.dimension) {
      throw new Error(
        `${context} dimension mismatch. Expected ${this.dimension}, got ${vector.length}`,
      );
    }

View on GitHub (pinned to 001c235229)

Solutions

  1. Convert arrays to an object form or string before passing them in algorithm parameters.
  2. Ensure every algorithm parameter value is a string, number, boolean, or a nested plain object of those.
  3. Log typeof for each config value before constructing the store if the error is unclear.

Example fix

// before
algorithmParams = { embeddingDimension: 1536, sources: ['s3://bucket'] };

// after
algorithmParams = { embeddingDimension: 1536, sources: 's3://bucket' };
Defensive patterns

Strategy: type-guard

Validate before calling

function assertSerializable(value: unknown): void {
  const t = typeof value;
  if (t !== 'string' && t !== 'number' && t !== 'boolean' && t !== 'object') {
    throw new TypeError(`Algorithm param of type ${t} cannot be serialized`);
  }
  if (t === 'object' && value !== null) Object.values(value as object).forEach(assertSerializable);
}
assertSerializable(algorithmParams);

Type guard

const isPlainSerializable = (v: unknown): boolean => {
  if (v === null) return true;
  const t = typeof v;
  return t === 'string' || t === 'number' || t === 'boolean' || (t === 'object' && !Array.isArray(v) && Object.values(v).every(isPlainSerializable));
};

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/1b4034113daa2cff. Report an issue: GitHub.