[CSHARP-4130] ChangeStreamOperationTypeSerializer doesn't handle dropDatabase Created: 06/Apr/22  Updated: 11/Apr/22  Resolved: 11/Apr/22

Status: Closed
Project: C# Driver
Component/s: Serialization
Affects Version/s: 2.15.0
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: Eric Rosenquist Assignee: Boris Dogadov
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CSHARP-4036 Do not error when parsing change stre... Closed

 Description   

Summary

When monitoring a change stream, an event of dropDatabase is not handled by the serializer and causes an exception if you attempt to access ChangeStreamDocument.OperationType.

 

System.FormatException: Invalid ChangeStreamOperationType: "dropDatabase".
 at MongoDB.Driver.ChangeStreamOperationTypeSerializer.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
 at MongoDB.Bson.Serialization.Serializers.SerializerBase`1.MongoDB.Bson.Serialization.IBsonSerializer.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
 at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize(IBsonSerializer serializer, BsonDeserializationContext context)
 at MongoDB.Bson.Serialization.BsonSerializationInfo.DeserializeValue(BsonValue value)
 at MongoDB.Bson.Serialization.BsonDocumentBackedClass.GetValue[T](String memberName, T defaultValue)
 at MongoDB.Driver.ChangeStreamDocument`1.get_OperationType()

 

Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

C# driver version is 2.15.0. Server version is 5.0.6 on a MongoDB Atlas shared cluster.

How to Reproduce

Connect to a cluster. Initiate a watch against the IMongoClient object. Drop a database in the cluster.



 Comments   
Comment by Boris Dogadov [ 11/Apr/22 ]

Thanks for reporting this eric_rosenquist@cysiv.com 
This issue is fixed in CSHARP-4036

Comment by Eric Rosenquist [ 06/Apr/22 ]

Since working around that issue I've noticed some related serialization problems - attempting to access CollectionNamespace will also throw an exception since there's no collection name for a dropDatabase change. I guess that's not surprising, but there needs to be a way to get the name of the dropped database without having to use Bson calls.

The exception is: System.ArgumentException: Collection names must be non-empty and not contain the null character. (Parameter 'collectionName')

Comment by Dmitry Lukyanov (Inactive) [ 06/Apr/22 ]

eric_rosenquist@cysiv.com thanks for your report. You're right, this change stream operation type is missed. We will triage this work and come back to you.

Generated at Wed Feb 07 21:47:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.