Forum Discussion

xguerin's avatar
xguerin
New member | Level 2
5 years ago

Documentation: UploadError marked as “open union”, is “datatype with subtype”

In /upload, the documentation gives UploadError as an open union, but is actually a datatype with subtype.

 

Here is an example of what the server returns:

 

 

{
  "error_summary": "path/conflict/folder/...",                                                                                                                                      
  "error": {                                                                                                                                                                        
    ".tag": "path",                                                                                                                                                                 
    "reason": {                                                                                                                                                                     
      ".tag": "conflict",                                                                                                                                                           
      "conflict": {".tag": "folder"}                                                                                                                                                
    },                                                                                                                                                                              
    "upload_session_id": "AAAAAAAAVfvllHwbx7wZGA"                                                                                                                                   
  }                                                                                                                                                                                 
}

 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    Thanks for the note, and apologies for the confusion. You can find information on how errors are structured in the documentation here. In this case, this part is relevant:

    Endpoint-specific errors (409)

    The following table describes the top-level JSON object attributes present in the body of 409 responses.

    Key Description
    error A value that conforms to the error data type schema defined in the definition of each route.

    So, for example, for /2/files/upload, the UploadError error type is referring to the value in the 'error' field, which can be either a 'path' or 'properties_error' (and is 'path' in your example here).

    • xguerin's avatar
      xguerin
      New member | Level 2

      Thank you Greg. I indeed agree with you about the content of the "error" field (being "path" in my example). However, IIRC, since the "UploadError" type is specified as an union, the ".tag" field is supposed to contain the name of the field in the union (as per the documentation). So I would have expected the following:

       

      {
        "error_summary": "path/conflict/folder/...",                                                                                                                                      
        "error": {                                                                                                                                                                        
          ".tag": "path",                                                                                                                                                                 
          “path”: {
            "reason": {                                                                                                                                                                     
              ".tag": "conflict",                                                                                                                                                           
              "conflict": {".tag": "folder"}                                                                                                                                                
            },                                                                                                                                                                              
            "upload_session_id": "AAAAAAAAVfvllHwbx7wZGA"
          }                                                                                                                                   
        }                                                                                                                                                                                 
      }

      The fact that the content of "UploadWriteFailed" are merged with the content of "UploadError" makes me think of a subtype, not union.

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        I see, thanks for clarifying. I believe the combined serialization is expected in this case, per the Stone documentation:

        Union members that are ordinary structs (coord in the example) serialize as the struct with the addition of a .tag key. 

        In this case, the UploadError union member UploadWriteFailed is a struct.

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API
Make connections with other developers803 PostsLatest Activity: 15 hours ago
216 Following

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!