I’m getting a null fullDocument on a change stream update event from the C# Mongo Change Streams API when ChangeStreamFullDocumentOption.UpdateLookup was set in the options. What are the ways in which this can happen? Can it happen if someone updates the object and sets it to an empty or null document?
Example code:
var options = new ChangeStreamOptions();
options.FullDocument = ChangeStreamFullDocumentOption.UpdateLookup;
using (var cursor = this.Database.Watch(options))
{
while (cursor.MoveNext())
{
if (!cursor.Current.Any())
{
break;
}
using (var enumerator = cursor.Current.GetEnumerator())
{
while (enumerator.MoveNext())
{
var document = enumerator.Current;
// evaluating the object
}
}
}
}
Here is the object that I was able to print out:
[21:37:23 INF] CHANGE STREAM DOCUMENT:
**BackingDocument:** ["_id={ \"_data\" : \"825E8A902B000000022B022C0100296E5A1004B805E49E7E3F45C781C4AB942B479670465A5F6964005A100408D7D9CFCB7D62096892F2000172E3CF0004\" }", "operationType=update", "clusterTime=6812415900709289986", **"fullDocument=BsonNull"**, "ns={ \"db\" : \"submission\", \"coll\" : \"SubmissionContainers\" }", "documentKey={ \"_id\" : CSUUID(\"08d7d9cf-cb7d-6209-6892-f2000172e3cf\") }", "updateDescription={ \"updatedFields\" : { \"lastModified\" : \"2020-04-06T02:12:58.7825657\", \"submission\" : { \"effectiveDate\" : \"2020-04-08\", \"workersCompensation\" : { \"employersLiability\" : { \"eachAccident\" : 100000, \"eachEmployee\" : 100000, \"eachPolicy\" : 500000 }, \"legalEntities\" : [{ \"businessType\" : \"LimitedLiabilityCompany\", \"states\" : [{ \"code\" : \"Colorado\", \"experienceModification\" : { \"factor\" : NumberDecimal(\"1\") }, \"locations\" : [{ \"exposure\" : [{ \"payroll\" : 300000, \"class\" : \"9083\", \"rate\" : NumberDecimal(\"0\"), \"hazardGroup\" : \"\\u0000\", \"overrideRate\" : false, \"state\" : \"0\" }], \"fullTimeEmployeeCount\" : 1, \"partTimeEmployeeCount\" : 1, \"address\" : { \"line1\" : \"P.O. Box 100\", \"city\" : \"Broomfield\", \"zip\" : \"80020\", \"state\" : \"Colorado\" } }] }], \"name\" : \"PPTEST: Testing 001\", \"taxId\" : \"121111111\" }] }, \"contacts\" : [{ \"firstName\" : \"ProdIshop\", \"lastName\" : \"Agent\", \"email\" : \"staging+PROD_ishop_agent@pieinsurance.com\", \"type\" : 5 }], \"namedInsured\" : \"PPTEST: Testing 001\" } }, \"removedFields\" : [] }"],
**FullDocument: null,**
DocumentKey: ["_id=UuidStandard:0x08d7d9cfcb7d62096892f2000172e3cf"],
ResumeToken: ["_data=825E8A902B000000022B022C0100296E5A1004B805E49E7E3F45C781C4AB942B479670465A5F6964005A100408D7D9CFCB7D62096892F2000172E3CF0004"],
UpdateDescription: MongoDB.Driver.ChangeStreamUpdateDescription,
CollectionNamespace: submission.SubmissionContainers,
OperationType: Update,
ClusterTime: 6812415900709289986