Skip to content

Inconsistent behaviour of dataset delete API #11253

@vera

Description

@vera

While testing the dataset delete API, I just noticed the following behavior, which was unexpected to me:

When logged in as a superuser, and then calling the delete API on a dataset with exactly one published version and no draft currently existing, the request seems to be automatically "upgraded" to a destroy action. The request succeeds and the dataset is deleted.

I expected the request to fail, since the delete API is not meant for deleting published datasets (at least according to the docs where the API is titled "Delete Unpublished Dataset" and the destroy API exists, which is in contrast meant for deleting published datasets as a superuser).

What makes the behavior even more confusing to me, as soon as more than one published version exists, the delete API always fails even when I'm a superuser (message: This is a published dataset with multiple versions. This API can only delete the latest version if it is a DRAFT).

When not logged in as a superuser, everything works as I expected (delete API succeeds for drafts but fails for published versions).

Here's the related code:

if (doomed.getVersions().size() == 1) {
if (doomed.isReleased() && (!(u instanceof AuthenticatedUser) || !u.isSuperuser())) {
throw new WrappedResponse(error(Response.Status.UNAUTHORIZED, "Only superusers can delete published datasets"));
}
destroy = true;
} else {
if (!doomedVersion.isDraft()) {
throw new WrappedResponse(error(Response.Status.UNAUTHORIZED, "This is a published dataset with multiple versions. This API can only delete the latest version if it is a DRAFT"));
}
}

And my question: Is this intended behavior? If yes, I think the special case (superuser + exactly one published version allows delete API to succeed) should be documented in the API docs.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    SPRINT READY

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions