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-287 - [BUG] Exception 27/08/2024 at 13:50 #1880

Closed
2 tasks
BenTopping opened this issue Aug 29, 2024 · 1 comment · Fixed by #1968
Closed
2 tasks

Y24-287 - [BUG] Exception 27/08/2024 at 13:50 #1880

BenTopping opened this issue Aug 29, 2024 · 1 comment · Fixed by #1968
Assignees
Labels
Bug Bug in code

Comments

@BenTopping
Copy link
Contributor

BenTopping commented Aug 29, 2024

Email subject line
[Psd-exceptions] [Limber PRODUCTION] print_jobs#create (NoMethodError) "undefined method `id' for nil:NilClass"

Error body

A NoMethodError occurred in print_jobs#create:

  undefined method `id' for nil:NilClass
  app/models/print_job.rb:138:in `pmb_label_template_id'

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.

@BenTopping BenTopping added the Bug Bug in code label Aug 29, 2024
@psd-issuer psd-issuer bot changed the title [BUG] print_jobs#create (NoMethodError) "undefined method 'id' for nil:NilClass" Y24-287 - [BUG] print_jobs#create (NoMethodError) "undefined method 'id' for nil:NilClass" Aug 29, 2024
@BenTopping BenTopping changed the title Y24-287 - [BUG] print_jobs#create (NoMethodError) "undefined method 'id' for nil:NilClass" Y24-287 - [BUG] Exception 27/08/2024 at 13:50 Aug 29, 2024
@BenTopping BenTopping self-assigned this Sep 30, 2024
@BenTopping
Copy link
Contributor Author

Fix linked in PR above.

Cause

When a label template which doesn't exist in print my barcode is attempted to be accessed in app/models/print_job.rb it throws an error. In this case it is the template 'sqsc_384plate_label_template_code39'. This template is documented as unusable but included 'for completeness', see comment here.

This was accessed because a user, presumably incorrectly, tried to print a 'plate_384_single' template to a toshiba printer. The toshiba printer is still selectable, despite not having a valid template, because limber displays all 384 printers and doesn't have a filter for print service type.

Fix

Handle label template check safely in app/models/print_job.rb for the case where the label template does not exist. It now provides a clear error message: Pmb Unable to find label template: <template_name>.

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.

1 participant