[CSHARP-1155] GridFS: "metadata" can be set to a value which causes an exception when the file is subsequently queried (or handled at all) Created: 23/Dec/14 Updated: 02/Mar/17 Resolved: 02/Mar/17 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | GridFS |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Andrew Ryder (Inactive) | Assignee: | Robert Stam |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | cs | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Description |
The above code when run the first time will give an exception at the last line. As:
The exception is generated internally by the C# driver when it assumes the 'metadata' field as a BsonDocument despite allowing us to set it to something else only a couple of lines above. In other words, the C# driver can create a GridFS entry that it can't load. All GridFS functions on this file entry are wedged. You cannot edit it, you cannot replace, update, or even delete it. The fatal trigger is SetMetadata, although using another driver to do the same operation is a viable alternative. Ultimately, inside the C# driver the presence of the "metadata" field causes an unstoppable type cast to occur when doing any operation with the tainted file entry - even just trying to delete it is fatal! For example, the following call now gives the same exception:
Knowing the file ID does not help, the following also causes the same exception:
The offending line of code for v1.9.2 is here: |
| Comments |
| Comment by Robert Stam [ 02/Mar/17 ] |
|
Since this only applies to the Legacy API and the Legacy API is no longer under active development this issue will not be fixed. The 2.x GridFS API does not have this issue. |
| Comment by Robert Stam [ 22/Dec/16 ] |
|
The GridFS spec requires that the metadata be a BsonDocument. SetMetadata should not have allowed the metadata to be set to anything other than a BsonDocument. In a future release we will add a SetMetadataDocument method that takes a BsonDocument parameter and deprecate the current SetMetadata method. Note also that this is the Legacy API. The new 2.x GridFS API does not have this issue. |