Skip to content

provider_job_id TypeError with SolidQueue: Integer passed where String expected #7

@justinko

Description

@justinko

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

  1. LogSubscriber (integrations/active_job/log_subscriber.rb) line 86:

    provider_job_id: job.provider_job_id,
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions