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: shared_link_already_exists just after list_shared_links returned nothing

shared_link_already_exists just after list_shared_links returned nothing

Slawek
New member | Level 2

I maintain an application which uploads files submitted by users and creates a shared link to them.

In most cases it works properly, but today one call to create_shared_link_with_settings returned 409 with the message shared_link_already_exists

It happened few hundred miliseconds after I called list_shared_links and received nothing.

 

Is there any reasonable explanation to this phenomena?

3 Replies 3

Greg-DB
Dropbox Staff
While it's technically possible the race condition occurred in this case (i.e., the link was created by some other client in between your two calls to list_shared_links and create_shared_link_with_settings), that is relatively unlikely given the short time span you indicated.

Is it possible your app called create_shared_link_with_settings twice somehow though? E.g., as an automatic retry in response to a network failure? That could cause this.

In any case though, you should implement error handling in your app for the shared_link_already_exists error, regardless of the timing of a previous call to list_shared_links.

Slawek
New member | Level 2

I call list_shared_links and create_shared_link_with_settings in the same function, so the first should discover any shared links created earlier, no matter how. That's my idea for this code ;).

 

In fact I have added this option only as a precaution, because the same function also uploads the file with autorename, so I don't expect any shared link for this file to exist.

Unless this error can be caused by sharing of the parent folder. Of course it would still be a race condition, which is very unprobable .

 

Is it possible to get shared_link_already_exists on the file just because a parent folder is shared?

Greg-DB
Dropbox Staff

Even though you call list_shared_links and create_shared_link_with_settings in the same function, there's still a race condition between the two calls, so you should make sure your call to create_shared_link_with_settings can always handle the possibility of a shared_link_already_exists error.

 

No, having a parent folder shared wouldn't cause a shared_link_already_exists error for a file in that folder.

Need more support?