title: MongoDB change stream returns empty fullDocument on insert
body: <p>Mongo 4.4 and respective Golang driver are used. Database’s replica set is being run locally at <code>localhost:27017</code>, <code>localhost:27020</code>. I’ve also tried using Atlas’s sandbox cluster which gave me the same results.</p>
  <p>According to Mongo's <a href="https://docs.mongodb.com/v4.4/reference/change-events/" rel="nofollow noreferrer">documentation</a> when handling insertion of a new document <code>fullDocument</code> field of event data is supposed to contain newly inserted document which for some reason is not the case for me. <code>ns</code> field where database and collection name are supposed to be and <code>documentKey</code> where affected document <code>_id</code> is stored are empty as well. <code>operationType</code> field contains correct operation type. In another test it appeared that update operations do not appear in a change stream at all.</p>
  <p>It used to work as it should but now it doesn't. Why does it happen and what am I doing wrong?</p>
  <h1>Code</h1>
  <pre><code>// ds is the connection to discord, required for doing stuff inside handlers
  func iterateChangeStream(stream *mongo.ChangeStream, ds *discordgo.Session, ctx context.Context, cancel context.CancelFunc) {
      defer stream.Close(ctx)
      defer cancel() // for graceful crashing
  
      for stream.Next(ctx) {
          var event bson.M
          err := stream.Decode(&amp;event)
          if err != nil {
              log.Print(errors.Errorf(&quot;Failed to decode event: %w\n&quot;, err))
              return
          }
  
          rv := reflect.ValueOf(event[&quot;operationType&quot;]) // getting operation type
          opType, ok := rv.Interface().(string)
          if !ok {
              log.Print(&quot;String expected in operationType\n&quot;)
              return
          }
          
          // event[&quot;fullDocument&quot;] will be empty even when handling insertion
          // models.Player is a struct representing a document of the collection
          // I'm watching over
          doc, ok := event[&quot;fullDocument&quot;].(models.Player)
          if !ok {
              log.Print(&quot;Failed to convert document into Player type&quot;)
              return
          }
          handlerCtx := context.WithValue(ctx, &quot;doc&quot;, doc)
          // handlerToEvent maps operationType to respective handler
          go handlerToEvent[opType](ds, handlerCtx, cancel)
      }
  }
  
  func WatchEvents(ds *discordgo.Session, ctx context.Context, cancel context.CancelFunc) {
  
      pipeline := mongo.Pipeline{
          bson.D{{
              &quot;$match&quot;,
              bson.D{{
                  &quot;$or&quot;, bson.A{
                      bson.D{{&quot;operationType&quot;, &quot;insert&quot;}}, // !!!
                      bson.D{{&quot;operationType&quot;, &quot;delete&quot;}},
                      bson.D{{&quot;operationType&quot;, &quot;invalidate&quot;}},
                  },
              }},
          }},
      }
      // mongo instance is initialized on program startup and stored in a global variable
      opts := options.ChangeStream().SetFullDocument(options.UpdateLookup)
      stream, err := db.Instance.Collection.Watch(ctx, pipeline, opts)
      if err != nil {
          log.Panic(err)
      }
      defer stream.Close(ctx)
  
      iterateChangeStream(stream, ds, ctx, cancel)
  }
  </code></pre>
  <p>My issue might be related to <a href="https://jira.mongodb.org/browse/SERVER-49161" rel="nofollow noreferrer">this</a>, except that it consistently occurs on insertion instead ocuring sometimes on updates.
  If you know how to enable change stream optimization feature flag mentioned inside link above, let me know.</p>
  <p>Feel free to ask for more clarifications.</p>