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

Y24-289 - [BUG] Exception 29/08/2024 at 15:28 #4310

Closed
2 tasks
harrietc52 opened this issue Aug 29, 2024 · 3 comments · Fixed by #4392
Closed
2 tasks

Y24-289 - [BUG] Exception 29/08/2024 at 15:28 #4310

harrietc52 opened this issue Aug 29, 2024 · 3 comments · Fixed by #4392
Assignees
Labels
Bug Bug in code

Comments

@harrietc52
Copy link
Contributor

Email subject line

[Psd-exceptions] [Sequencescape Production] searches#index (ActionView::Template::Error) "uninitialized constant Barcode::FormatHandlers:...

Error body

An ActionView::Template::Error occurred in searches#index:

  uninitialized constant Barcode::FormatHandlers::AkerBarcode
  app/models/barcode.rb:222:in `const_get'

Acceptance Criteria

  • Look into this exception and fix the code to handle the exception sensibly.
  • Document the root cause and solution in a comment on this issue.

Additional information

The id of the user who triggered this error is often shown in the exception email, in case you need to communicate with them.

@harrietc52 harrietc52 added the Bug Bug in code label Aug 29, 2024
@psd-issuer psd-issuer bot changed the title [BUG] Exception 29/08/2024 at 15:28 Y24-289 - [BUG] Exception 29/08/2024 at 15:28 Aug 29, 2024
@wendyyang wendyyang self-assigned this Oct 1, 2024
@stevieing
Copy link
Contributor

@wendyyang More context. This is happening because someone is running a Sequencescape search /searches?type=&q=7747.

It looks like they are doing a search for study 7747 but because they are not specifiying a type it is actually looking for everything with an id of 7747.

We probably don't want it to fail but it is worth a check on how it is handled.

It will be difficult to reproduce in UAT as we might not have any Aker barcodes in the table.

@neilsycamore
Copy link
Contributor

neilsycamore commented Oct 2, 2024

This exception is raised in the Sequencescape console when calling labwhere_location on a Labware object that has an aker_format (id = 4) barcode AND/OR calling human_barcode
e.g.
l = Labware.find 23061777
l.labwhere_location
/var/www/sequencescape/releases/20240920142713/app/models/barcode.rb:222:in `const_get': uninitialized constant Barcode::FormatHandlers::AkerBarcode (NameError)

l.human_barcode
/var/www/sequencescape/releases/20240920142713/app/models/barcode.rb:222:in `const_get': uninitialized constant Barcode::FormatHandlers::AkerBarcode (NameError)

Barcode::FormatHandlers.const_get(handler_class_name, false)
                       ^^^^^^^^^^

I've come across this when writing reports in Ruby and have handled this with:

class Labware
  def find_location()
    if self.barcodes.map(&:format).include?("aker_barcode")
      location = nil
    else
      location = self.labwhere_location
    end
    return location
  end
  
  def find_barcode()
    if self.barcodes.empty?
      barcode = "Not found"
      return barcode
    else
      bad = ["external","aker_barcode"]
      barcode = self.barcodes.where.not(format: bad).first.barcode
      return barcode
    end
  end
end

@neilsycamore
Copy link
Contributor

barcodes = Barcode.where(format:4)
labware  = barcodes.map(&:asset)

using the above method

labware.map(&:find_barcode)
=> ["NT1457915H", "DN537747W", "DN537868H", "DN537869I", "DN537870B", "DN538319K", "NT1462400Q", "DN538443N", "DN552057Q"]

DN537747W is the barcode being matched in the search

@wendyyang wendyyang linked a pull request Oct 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug in code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants