cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: SwiftyDropbox - how to catch improperly formatted path

SwiftyDropbox - how to catch improperly formatted path

vewert
Explorer | Level 4
Go to solution

If I make a call, (e.g. using listFolder), and I pass in an invalid path argument, (e.g. no leading slash), I get the following error:

 

precondition failed: "Does not exist must match pattern "\A(?:(/(.|[\r\n])*)?|id:.*|(ns:[0-9]+(/.*)?))\z":

 

I understand why the error occurs, but the error seems to occur, before the call gets made, and doesn't show up, when I check the response for an error. My question is, how can I catch this kind of error of the path argument?

 

Thanks

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution
The SDK has a copy of the API specification and can tell when the supplied value isn't valid without making a call to the server (and thus without going through the API error callback).

You'll need to prevent your app from using invalid values like this in the first place. E.g., only use safe values returned by the API, such as in Metadata.pathLower, or just "" for root. If your app allows the user to manually enter in path values, you'll need to check them against the pattern in that error message first.

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution
The SDK has a copy of the API specification and can tell when the supplied value isn't valid without making a call to the server (and thus without going through the API error callback).

You'll need to prevent your app from using invalid values like this in the first place. E.g., only use safe values returned by the API, such as in Metadata.pathLower, or just "" for root. If your app allows the user to manually enter in path values, you'll need to check them against the pattern in that error message first.

vewert
Explorer | Level 4
Go to solution

That makes sense. I'll make sure my app uses only valid values for path.

 

Thanks again for your quick and helpful response.

Need more support?