Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 500 when providing the uuid for a sample in the previous_revision_uuid field for create_entity #420

Open
DerekFurstPitt opened this issue Jan 17, 2023 · 0 comments

Comments

@DerekFurstPitt
Copy link
Contributor

In entities/<entity_type> (create_entity), for the field previous_version_uuid, the code allows for this uuid to be for either datasets or samples.

# Make sure the previous version entity is either a Dataset or Sample
if previous_version_dict['entity_type'] not in ['Dataset', 'Sample']:
    bad_request_error(f"The previous_revision_uuid specified for this dataset must either be a Dataset or Sample"

However, if the uuid for a sample is given, a 500 will be raised when the following section of the code is reached:

# Only published datasets can have revisions made of them. Verify that the status of the Dataset specified
# by previous_revision_uuid is published. Else, bad request error. 
if previous_version_dict['status'].lower() != DATASET_STATUS_PUBLISHED:
    bad_request_error(f"The previous_revision_uuid specified for this dataset must be 'Published' in order to create a new revision from it")

Since samples do not contain status field, the error occurs. Either move this status check under a conditional if previous_version_dict['entity_type'] == "Dataset" or modify the earlier conditional to only include datasets and not datasets or samples. Previous revision should never be a sample so this seems to be the better option.

Unless something entirely different was intended, in which case this whole section may need modified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready
Development

No branches or pull requests

1 participant