-
Notifications
You must be signed in to change notification settings - Fork 116
Open
Labels
bugConfirmed and unconfirmed bugs reported by us and customers.Confirmed and unconfirmed bugs reported by us and customers.
Description
Describe the bug
ActiveJobClassInstrumentation#transaction_set_error raises NoMethodError: undefined method 'set_error' for nil:NilClass when the transaction argument is nil. This happens in SolidQueue worker threads when Appsignal::Transaction.create fails and the job subsequently raises an exception.
To Reproduce
Steps to reproduce the behavior:
- Use SolidQueue as the ActiveJob backend
- A job fails in a SolidQueue worker thread where
Appsignal::Transaction.createdid not succeed - The rescue block in
ActiveJobClassInstrumentation#executecallstransaction_set_error(nil, exception) transaction_set_errorcallsnil.set_error(exception)β NoMethodError
Error
SolidQueue-1.3.2 Error in thread (0.0ms) error: "NoMethodError undefined method `set_error' for nil:NilClass"
Traceback points to lib/appsignal/hooks/active_job.rb:122.
Root cause
In lib/appsignal/hooks/active_job.rb:
def transaction_set_error(transaction, exception)
return unless Appsignal.config[:activejob_report_errors] == "all"
transaction.set_error(exception) # β no nil guard
endThe method checks the config but does not check if transaction is nil before calling .set_error.
Suggested fix
def transaction_set_error(transaction, exception)
return unless transaction
return unless Appsignal.config[:activejob_report_errors] == "all"
transaction.set_error(exception)
end
Environment
Ruby: 3.2.4
Rails: 7.1.1
appsignal: 4.8.3 (also reproducible on 3.7.5)
solid_queue: 1.3.2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugConfirmed and unconfirmed bugs reported by us and customers.Confirmed and unconfirmed bugs reported by us and customers.