Closed mathuin closed 7 years ago
To clarify right now and for whoever fixes these docs, the answer is that if any of the slugs provided belong to any other projects (regardless whether they're the same or different projects, and regardless of permissions), a Slug Already Exists error is returned containing the list of slugs already associate with a project. Otherwise, the project's slugs are set to precisely the list provided.
Your response does not address what happens to the project if not all slugs being POSTed currently exist. Since the presence of at least one existing slug causes an error to return, are the other non-existing slugs successfully set? How does the client know that some parts succeeded and some parts failed?
In the event that any error occurs during a POST or DELETE operation, an error is returned to the client, and the operation is terminated. As is consistent with the behavior of all of the rest of the API, if at least one slug already belongs to another project, a Slug Already Exists error is returned, and the project is not modified.
https://timesync.readthedocs.io/en/latest/api.html#post-projects-slug
The following text is included as a note block:
I thought I understood, until I got to the parenthetical portion of the text. This needs examples or some additional clarification. If a project has slugs ["a", "b"], and a slugs field of ["b"] is POSTed to that project, the "a" slug is dropped. If a slugs field of ["c", "d"] is POSTed to that project and no other project has those slugs, then both "a" and "b" are dropped, and "c" and "d" are the only slugs for this project. If a slugs field of ["c", "d"] is POSTed to that project but another project has "c" as a slug, what happens? What if one project has "c" and another project has "d"? What if the user POSTing does not have sufficient privilege to see one or more of the projects holding those other slugs?