dropbox-sdk-js: API inconsistency: "filesDownload" returns an error as a string instead of an object

Version: “dropbox”: “^5.1.0”

If I provide a wrong path structure to filesDownload, Dropbox throws path/malformed_path/.. error.

The problem is that this error object provides data in a serialized (string) format and not as an object: 20_134121

This makes it more difficult to handle an error.

In contrast, filesUpload returns the same error as an object: 20_134544

It looks like somewhere in filesDownload there is an issue with JSON.stringify(…)/JSON.parse(…).

Please, make it consistent as an object.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks for the report! I’ll ask the team to fix this up.

Hello, I am able to reproduce this issue but am unable to reproduce the desired outcome you said you were unable to achieve with filesUpload.

The sample code I used looks like this:

const dbx =new Dropbox({accessToken: 'redacted'});
dbx.filesDownload({
    "path": "/malformed/path/"
}).then((response) => {
}).catch((error) => {
    console.log(typeof error.error);
    console.log('Error: ' + error.error);
    console.log('Error_Summary: ' + error.error.error_summary);
});

dbx.filesUpload({
    "path": "/malformed/path/"
}).then((response) => {
}).catch((error) => {
    console.log(typeof error.error);
    console.log('Error: ' + error.error);
    console.log('Error_Summary: ' + error.error.error_summary);
});

And the output looks like this:

string Error: {“error_summary”: “path/malformed_path/…”, “error”: {“.tag”: “path”, “path”: {“.tag”: “malformed_path”}}} Error_Summary: undefined string Error: {“error_summary”: “path/malformed_path/…”, “error”: {“.tag”: “path”, “reason”: {“.tag”: “malformed_path”}, “upload_session_id”: “redacted”}} Error_Summary: undefined

As you can see both return a string type. While I can make the change to have these return a JSON object, I am trying to see how you were able to get upload to return an object. Could you paste some code snippets?

Similar issue after fixing https://github.com/dropbox/dropbox-sdk-js/issues/336 / https://github.com/dropbox/dropbox-sdk-js/issues/336. Error message is stringified instead of being an easy-to-use object: 13_003142