Summary
When using SolidQueue as the Active Job backend, logstruct raises a TypeError when logging job events:
Parameter 'provider_job_id': Can't set LogStruct::Log::ActiveJob::BaseFields.provider_job_id to 2905 (instance of Integer) - need a String
Root cause
LogStruct::Log::ActiveJob::BaseFields types provider_job_id as T.nilable(String)
- SolidQueue sets
provider_job_id to an Integer (the database primary key of the solid_queue_jobs record)
LogStruct::Integrations::ActiveJob::LogSubscriber#build_base_fields passes job.provider_job_id directly without conversion
Affected code
-
LogSubscriber (integrations/active_job/log_subscriber.rb) line 86:
provider_job_id: job.provider_job_id,
-
Builders::ActiveJob (builders/active_job.rb) safe_provider_job_id returns the raw value without .to_s
Suggested fix
Convert provider_job_id to a string in both places, since Active Job backends may return either String or Integer:
- In
build_base_fields: provider_job_id: job.provider_job_id&.to_s
- In
safe_provider_job_id: return raw&.to_s instead of raw
Workaround
Until fixed, we use an initializer that monkey-patches build_base_fields to call .to_s on provider_job_id.
Summary
When using SolidQueue as the Active Job backend, logstruct raises a
TypeErrorwhen logging job events:Root cause
LogStruct::Log::ActiveJob::BaseFieldstypesprovider_job_idasT.nilable(String)provider_job_idto an Integer (the database primary key of thesolid_queue_jobsrecord)LogStruct::Integrations::ActiveJob::LogSubscriber#build_base_fieldspassesjob.provider_job_iddirectly without conversionAffected code
LogSubscriber (
integrations/active_job/log_subscriber.rb) line 86:Builders::ActiveJob (
builders/active_job.rb)safe_provider_job_idreturns the raw value without.to_sSuggested fix
Convert
provider_job_idto a string in both places, since Active Job backends may return either String or Integer:build_base_fields:provider_job_id: job.provider_job_id&.to_ssafe_provider_job_id: returnraw&.to_sinstead ofrawWorkaround
Until fixed, we use an initializer that monkey-patches
build_base_fieldsto call.to_sonprovider_job_id.