Automattic/mongoose · error · MongooseError

Invalid BSON type for FLE field: '${path}'

Error message

Invalid BSON type for FLE field: '${path}'

What it means

Error "Invalid BSON type for FLE field: '${path}'" thrown in Automattic/mongoose.

Source

Thrown at lib/schema.js:955

  }

  const aliasObj = Object.fromEntries(
    Object.entries(obj).map(([key]) => ([prefix + key, null]))
  );
  aliasFields(this, aliasObj);
  return this;
};

/**
 * @param {string} path
 * @param {object} fieldConfig
 *
 * @api private
 */
Schema.prototype._addEncryptedField = function _addEncryptedField(path, fieldConfig) {
  const type = this.path(path).autoEncryptionType();
  if (type == null) {
    throw new MongooseError(`Invalid BSON type for FLE field: '${path}'`);
  }

  this.encryptedFields[path] = clone(fieldConfig);
};

/**
 * @param {string} path
 *
 * @api private
 */
Schema.prototype._removeEncryptedField = function _removeEncryptedField(path) {
  delete this.encryptedFields[path];
};

/**
 * @api private
 *
 * @returns {boolean}

View on GitHub (pinned to 49cdab0136)

When it happens

Trigger: Thrown at lib/schema.js:955 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Automattic/mongoose@49cdab0136 (2026-08-21). Data as JSON: /api/errors/f2628cafafc3aef1. Report an issue: GitHub.