Skip to content

Return undef when a tissue sample has no plate or trial - #6289

Open
shbrainard wants to merge 1 commit into
solgenomics:masterfrom
shbrainard:fix/tissue-sample-no-plate-500
Open

Return undef when a tissue sample has no plate or trial#6289
shbrainard wants to merge 1 commit into
solgenomics:masterfrom
shbrainard:fix/tissue-sample-no-plate-500

Conversation

@shbrainard

Copy link
Copy Markdown
Contributor

_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.

_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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant