<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:39:46 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CSHARP-1493] Unable to cast object exception thrown when trying to access FileInfo.Id from GridFs.FindAsync() results</title>
                <link>https://jira.mongodb.org/browse/CSHARP-1493</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;I migrated from the legacy driver to the new implementation of GridFs and when I run a FindAsync() that returns files that were previously stored with legacy version an invalid cast exception is thrown when trying to access the ObjectId via FileInfo.Id property. &lt;/p&gt;

&lt;p&gt;I am wondering if this is a result of earlier code we had that set the Id during upload? My assumption is that these Id&apos;s are not compatible with ObjectId. [GridFs.Upload(file, id, new MongoGridFSCreateOptions() &lt;/p&gt;
{ Id = id }
&lt;p&gt;);]&lt;/p&gt;


&lt;p&gt;Details of Exception&lt;/p&gt;

&lt;p&gt;fileInfo.Id&lt;br/&gt;
&apos;fileInfo.Id&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    Data: &lt;/p&gt;
{System.Collections.ListDictionaryInternal}
&lt;p&gt;    HResult: -2147467262&lt;br/&gt;
    HelpLink: null&lt;br/&gt;
    InnerException: null&lt;br/&gt;
    Message: &quot;Unable to cast object of type &apos;MongoDB.Bson.BsonString&apos; to type &apos;MongoDB.Bson.BsonObjectId&apos;.&quot;&lt;br/&gt;
    Source: &quot;MongoDB.Driver.GridFS&quot;&lt;br/&gt;
    StackTrace: &quot;   at MongoDB.Driver.GridFS.GridFSFileInfo.get_Id()&quot;&lt;br/&gt;
    TargetSite: &lt;/p&gt;
{MongoDB.Bson.ObjectId get_Id()}


&lt;p&gt;fileInfo.IdAsBsonValue&lt;/p&gt;
{55b66883acaf044ce05919ff}&lt;br/&gt;
    AsBoolean: &apos;fileInfo.IdAsBsonValue.AsBoolean&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsBsonArray: &apos;fileInfo.IdAsBsonValue.AsBsonArray&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsBsonBinaryData: &apos;fileInfo.IdAsBsonValue.AsBsonBinaryData&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsBsonDateTime: &apos;fileInfo.IdAsBsonValue.AsBsonDateTime&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsBsonDocument: &apos;fileInfo.IdAsBsonValue.AsBsonDocument&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsBsonJavaScript: &apos;fileInfo.IdAsBsonValue.AsBsonJavaScript&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsBsonJavaScriptWithScope: &apos;fileInfo.IdAsBsonValue.AsBsonJavaScriptWithScope&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsBsonMaxKey: &apos;fileInfo.IdAsBsonValue.AsBsonMaxKey&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsBsonMinKey: &apos;fileInfo.IdAsBsonValue.AsBsonMinKey&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsBsonNull: &apos;fileInfo.IdAsBsonValue.AsBsonNull&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsBsonRegularExpression: &apos;fileInfo.IdAsBsonValue.AsBsonRegularExpression&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsBsonSymbol: &apos;fileInfo.IdAsBsonValue.AsBsonSymbol&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsBsonTimestamp: &apos;fileInfo.IdAsBsonValue.AsBsonTimestamp&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsBsonUndefined: &apos;fileInfo.IdAsBsonValue.AsBsonUndefined&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsBsonValue: {55b66883acaf044ce05919ff}
&lt;p&gt;    AsByteArray: &apos;fileInfo.IdAsBsonValue.AsByteArray&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsDateTime: &apos;fileInfo.IdAsBsonValue.AsDateTime&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsDouble: &apos;fileInfo.IdAsBsonValue.AsDouble&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsGuid: &apos;fileInfo.IdAsBsonValue.AsGuid&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsInt32: &apos;fileInfo.IdAsBsonValue.AsInt32&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsInt64: &apos;fileInfo.IdAsBsonValue.AsInt64&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsLocalTime: &apos;fileInfo.IdAsBsonValue.AsLocalTime&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsNullableBoolean: &apos;fileInfo.IdAsBsonValue.AsNullableBoolean&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsNullableDateTime: &apos;fileInfo.IdAsBsonValue.AsNullableDateTime&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsNullableDouble: &apos;fileInfo.IdAsBsonValue.AsNullableDouble&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsNullableGuid: &apos;fileInfo.IdAsBsonValue.AsNullableGuid&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsNullableInt32: &apos;fileInfo.IdAsBsonValue.AsNullableInt32&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsNullableInt64: &apos;fileInfo.IdAsBsonValue.AsNullableInt64&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsNullableObjectId: &apos;fileInfo.IdAsBsonValue.AsNullableObjectId&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsObjectId: &apos;fileInfo.IdAsBsonValue.AsObjectId&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsRegex: &apos;fileInfo.IdAsBsonValue.AsRegex&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    AsString: &quot;55b66883acaf044ce05919ff&quot;&lt;br/&gt;
    AsUniversalTime: &apos;fileInfo.IdAsBsonValue.AsUniversalTime&apos; threw an exception of type &apos;System.InvalidCastException&apos;&lt;br/&gt;
    BsonType: String&lt;br/&gt;
    IsBoolean: false&lt;br/&gt;
    IsBsonArray: false&lt;br/&gt;
    IsBsonBinaryData: false&lt;br/&gt;
    IsBsonDateTime: false&lt;br/&gt;
    IsBsonDocument: false&lt;br/&gt;
    IsBsonJavaScript: false&lt;br/&gt;
    IsBsonJavaScriptWithScope: false&lt;br/&gt;
    IsBsonMaxKey: false&lt;br/&gt;
    IsBsonMinKey: false&lt;br/&gt;
    IsBsonNull: false&lt;br/&gt;
    IsBsonRegularExpression: false&lt;br/&gt;
    IsBsonSymbol: false&lt;br/&gt;
    IsBsonTimestamp: false&lt;br/&gt;
    IsBsonUndefined: false&lt;br/&gt;
    IsDateTime: false&lt;br/&gt;
    IsDouble: false&lt;br/&gt;
    IsGuid: false&lt;br/&gt;
    IsInt32: false&lt;br/&gt;
    IsInt64: false&lt;br/&gt;
    IsNumeric: false&lt;br/&gt;
    IsObjectId: false&lt;br/&gt;
    IsString: true&lt;br/&gt;
    IsValidDateTime: false&lt;br/&gt;
    RawValue: &quot;55b66883acaf044ce05919ff&quot;&lt;br/&gt;
    Value: &quot;55b66883acaf044ce05919ff&quot;&lt;/p&gt;</description>
                <environment></environment>
        <key id="242439">CSHARP-1493</key>
            <summary>Unable to cast object exception thrown when trying to access FileInfo.Id from GridFs.FindAsync() results</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="cs-NET">Christian Sleight [X]</reporter>
                        <labels>
                    </labels>
                <created>Sat, 5 Dec 2015 20:14:18 +0000</created>
                <updated>Sat, 5 Dec 2015 20:59:15 +0000</updated>
                            <resolved>Sat, 5 Dec 2015 20:59:15 +0000</resolved>
                                    <version>2.1.1</version>
                                                    <component>GridFS</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1106390" author="rstam" created="Sat, 5 Dec 2015 20:59:06 +0000"  >&lt;p&gt;The GridFS spec requires that the Id for all new GridFS files be of type ObjectId.&lt;/p&gt;

&lt;p&gt;Drivers may optionally support reading existing GridFS files where the Id is not an ObjectId.&lt;/p&gt;

&lt;p&gt;To access the Id where the value is not an ObjectId, use the IdAsBsonValue property instead of the Id property of the GridFSFileInfo class.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hset27:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>