ValidatorError: Cannot read property 'options' of undefined on undefined field
<p>I have <code>Shape</code> and <code>ShapeOrientation</code> models. A shape can have many shape orientations. So my models are as follows: </p>

<pre><code>var shapeSchema = new mongoose.Schema({
  name: { type: String },
  mfrID: { type: String },
  category: { type: mongoose.Schema.Types.ObjectId, ref: 'ShapeCategory' },
  brand: { type: mongoose.Schema.Types.ObjectId, ref: 'ShapeBrand' },
  available: { type: Boolean, default: false },
  related: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Shape' }],
  orientations: [{ type: mongoose.Schema.Types.ObjectId, ref: 'ShapeOrientation' }],
  owner: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
  open: { type: Boolean, default: true },
  thumb: { type: String },
  thumbMime: { type: String },
  thumbPath: { type: String },
  shapeid: { type: String },
  desc: { type: String },
  verified: { type: Boolean, default: true }
</code></pre>

<p>My Shape Orientation Schema is thus: </p>

<pre><code>var shapeOrientationSchema = new mongoose.Schema({
  name: { type: String },
  data: { type: String },
  shape: { type: mongoose.Schema.Types.ObjectId, ref: 'Shape' },
  shapeid: { type: String },
  length: { type: Number },
  width: { type: Number },
  depth: { type: Number },
  thumb: { type: String },
  thumbMime: { type:String }
});
</code></pre>

<p>When I try to populate my shape orientations and shape at the same time for a massive import. </p>

<pre><code>ShapeOrientation.insertMany(orientations)
  .then(function(manyDocs){
    console.log('hooked up and saved orientations.');
    async.eachSeries(manyDocs, function(orientDoc, orientDone) {
      Shape.findOne({shapeid: orientDoc.shapeid})
      .then(function(foundShape){
        foundShape.orientations.push(orientDoc._id);
        foundShape.save(function(err) {
          if(err) {
            console.log('shape', foundShape)
            console.log('cannot save shape', err)
            orientDone();
            return;
          } else {
            orientDone();
          }
          console.log('saved shape')
        })
      })
    })
</code></pre>

<p>I get the following error on an <code>undefined</code> field of mongo.</p>

<pre><code>cannot save shape { [ValidationError: Shape validation failed]
  message: 'Shape validation failed',
  name: 'ValidationError',
  errors:
   { undefined:
      { [ValidatorError: Cannot read property 'options' of undefined]
        properties: [Object],
        message: 'Cannot read property \'options\' of undefined',
        name: 'ValidatorError',
        kind: 'cast',
        path: undefined,
        value: undefined } } }
</code></pre>

<p>I don't seem to have any required fields and I am just trying to save the related data while I populate the orientation. </p>

<p>Both <code>_.id</code>'s of the Shape and the Orientation exist so I don't understand why it won't save. </p>