Return undef when a tissue sample has no plate or trial - #6289
Open
shbrainard wants to merge 1 commit into
Open
Conversation
_retrieve_plate and _retrieve_trial raised an exception when the query for the sample's genotyping or field project returned a count other than one. Both are builders for Moose attributes declared with lazy => 1, so each runs the first time get_plate or get_trial is read rather than when the object is constructed. CXGN::Stock::TissueSample::Search reads both accessors for every row it returns. A single sample without a plate therefore caused GET /brapi/v2/samples to return HTTP 500 for the whole request, including the genotyping plate samples in the same page. Because the exception came from the accessor and not from the constructor, wrapping the call to new in an eval did not prevent it. Tissue samples without a genotyping project are created by two existing tools: the field-trial tissue sample tool at /breeders/trial/<id>/create_tissue_samples, and sampling trials. One sample from either tool was sufficient to make the endpoint return HTTP 500 on every request. Both subroutines now return without setting the attribute, which leaves it undefined. CXGN::BrAPI::v2::Samples tests get_plate and get_trial for truth before using them, in both detail and search, so the undefined value is handled by the existing callers. The behavior was observed on a local instance. On a trial with plots and no tissue samples, GET /brapi/v2/samples returned 200. After create_plant_entries and create_tissue_samples were posted for that trial, the same request returned 500. With this change applied, the request returned 200 and included the new samples, reporting a null plate and the field trial as the study.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_retrieve_plate and _retrieve_trial raised an exception when the query
for the sample's genotyping or field project returned a count other than
one. Both are builders for Moose attributes declared with lazy => 1, so
each runs the first time get_plate or get_trial is read rather than when
the object is constructed. CXGN::Stock::TissueSample::Search reads both
accessors for every row it returns. A single sample without a plate
therefore caused GET /brapi/v2/samples to return HTTP 500 for the whole
request, including the genotyping plate samples in the same page.
Because the exception came from the accessor and not from the
constructor, wrapping the call to new in an eval did not prevent it.
Tissue samples without a genotyping project are created by two existing
tools: the field-trial tissue sample tool at
/breeders/trial//create_tissue_samples, and sampling trials. One
sample from either tool was sufficient to make the endpoint return HTTP
500 on every request.
Both subroutines now return without setting the attribute, which leaves
it undefined. CXGN::BrAPI::v2::Samples tests get_plate and get_trial for
truth before using them, in both detail and search, so the undefined
value is handled by the existing callers.
The behavior was observed on a local instance. On a trial with plots and
no tissue samples, GET /brapi/v2/samples returned 200. After
create_plant_entries and create_tissue_samples were posted for that
trial, the same request returned 500. With this change applied, the
request returned 200 and included the new samples, reporting a null
plate and the field trial as the study.