We Want to Hear From You! What Do You Want to See on the Community? Tell us here!
Forum Discussion
6EHPS2
6 years agoExplorer | Level 3
ListFolderAsync() throws InvalidCastException when file or folder name is ISO-8601 date
Description
When a file or a folder exists with a name that is an ISO-8601 date (such as "2019-12-25T23:58:05"), the ListFolderAsync() method fails by throwing a System.InvalidCastException.
Steps to reproduce
- Create a folder test in the root folder of your Dropbox.
- Upload a file with the name 2019-12-25T23:58:05 to the folder /test or create a new folder with that name as a subfolder of the folder /test. Make sure that there is no file extension.
- Run the following C# program, after providing a valid access token:
public class Program { static void Main(string[] args) { using var dbx = new DropboxClient(oauth2AccessToken: "..."); var result = dbx.Files.ListFolderAsync( path: "/test" ).GetAwaiter().GetResult(); } }
Expected result
The method should return a list of Dropbox.Api.Files.Metadata objects, including one object representing the file or folder created above.
Actual result
The program crashes with the following exception:
System.InvalidCastException HResult=0x80004002 Message=Value '12/25/2019 23:58:05' is not valid System.String type Source=Dropbox.Api StackTrace: at Dropbox.Api.Stone.JsonReader.ReadValue[T]() at Dropbox.Api.Stone.JsonReader.Dropbox.Api.Stone.IJsonReader.ReadString() at Dropbox.Api.Stone.StringDecoder.Decode(IJsonReader reader) at Dropbox.Api.Files.FileMetadata.FileMetadataDecoder.SetField(FileMetadata value, String fieldName, IJsonReader reader) at Dropbox.Api.Stone.StructDecoder`1.DecodeFields(IJsonReader reader) at Dropbox.Api.Files.Metadata.MetadataDecoder.Decode(String tag, IJsonReader reader) at Dropbox.Api.Stone.UnionDecoder`1.DecodeFields(IJsonReader reader) at Dropbox.Api.Stone.StructDecoder`1.Decode(IJsonReader reader) at Dropbox.Api.Stone.ListDecoder`1.TryReadArrayItem(IJsonReader reader, IDecoder`1 decoder, T& value) at Dropbox.Api.Stone.ListDecoder`1.Decode(IJsonReader reader, IDecoder`1 itemDecoder) at Dropbox.Api.Stone.StructDecoder`1.ReadList[TItem](IJsonReader reader, IDecoder`1 itemDecoder) at Dropbox.Api.Files.ListFolderResult.ListFolderResultDecoder.SetField(ListFolderResult value, String fieldName, IJsonReader reader) at Dropbox.Api.Stone.StructDecoder`1.DecodeFields(IJsonReader reader) at Dropbox.Api.Stone.StructDecoder`1.Decode(IJsonReader reader) at Dropbox.Api.Stone.JsonReader.Read[T](String json, IDecoder`1 decoder) at Dropbox.Api.DropboxRequestHandler.<Dropbox-Api-Stone-ITransport-SendRpcRequestAsync>d__12`3.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in /_/src/System.Private.CoreLib/shared/System/Runtime/ExceptionServices/ExceptionDispatchInfo.cs:line 63 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) in /_/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs:line 180 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) in /_/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs:line 151 at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() in /_/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs:line 369 at DropboxUpload.Program.Main(String[] args) in C:\my\vs\repos\DropboxUpload\Program.cs:line 681 This exception was originally thrown at this call stack: Dropbox.Api.Stone.JsonReader.ReadValue<T>() Dropbox.Api.Stone.JsonReader.Dropbox.Api.Stone.IJsonReader.ReadString() Dropbox.Api.Stone.StringDecoder.Decode(Dropbox.Api.Stone.IJsonReader) Dropbox.Api.Files.FileMetadata.FileMetadataDecoder.SetField(Dropbox.Api.Files.FileMetadata, string, Dropbox.Api.Stone.IJsonReader) Dropbox.Api.Stone.StructDecoder<T>.DecodeFields(Dropbox.Api.Stone.IJsonReader) Dropbox.Api.Files.Metadata.MetadataDecoder.Decode(string, Dropbox.Api.Stone.IJsonReader) Dropbox.Api.Stone.UnionDecoder<T>.DecodeFields(Dropbox.Api.Stone.IJsonReader) Dropbox.Api.Stone.StructDecoder<T>.Decode(Dropbox.Api.Stone.IJsonReader) Dropbox.Api.Stone.ListDecoder<T>.TryReadArrayItem(Dropbox.Api.Stone.IJsonReader, Dropbox.Api.Stone.IDecoder<T>, out T) Dropbox.Api.Stone.ListDecoder<T>.Decode(Dropbox.Api.Stone.IJsonReader, Dropbox.Api.Stone.IDecoder<T>) ... [Call Stack Truncated]
2 Replies
- Greg-DB6 years ago
Dropbox Community Moderator
Thank you for the well written bug report! I can reproduce this issue here. We'll look into it and I'll follow up on this thread once I have an update on it from the team.
- Greg-DB5 years ago
Dropbox Community Moderator
This should be fixed as of v6.0.1 of the SDK.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,036 PostsLatest Activity: 3 hours ago
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!