question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API inconsistency: "filesDownload" returns an error as a string instead of an object

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
greg-dbcommented, Jun 22, 2020

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

1reaction
rogebrdcommented, Oct 23, 2020

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular4 - Http error returned is a string instead of an object
I'm doing an Http request in Angular 4 using its builtin HttpClient class. Everything works well, but there is a small problem with...
Read more >
Inconsistent API response for passing strings exceeding 255 ...
I'm working on error handling and want to be sure I'm covering some bases to provide more suitable user-facing error messaging.
Read more >
D.R.S Dz - Autopistas de la Sabana
Fixed drupal_render() to always return an empty string when there is no output, rather than sometimes returning NULL (minor API change).
Read more >
Errors | Node.js v19.3.0 Documentation
Creates a .stack property on targetObject , which when accessed returns a string representing the location in the code at which Error.
Read more >
Modifying the PowerBuilder client app - - PowerServer 2022 Help
Uses the identity token to access data from the PowerServer Web API. ... Case 240 to 249 //Token Error MessageBox ("Token Error", "Number:"...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found