Oban add_workflow/4 with put_context/2 in a sub-workflow

Environment

  • Oban Pro: 1.6.2
  • Oban: 2.19.4

The Issue

I have some workflows IngestionWorkflow and MapperWorkflow, each of which looks something like this:

defmodule MapperWorkflow do
  def build(source_name, opts \\ []) do

    # ...

    Workflow.new()
    |> Workflow.put_context(%{
      source_name: to_string(source_name),
      batch_size: batch_size,
      since: since
    })
    |> Workflow.add_graft(:mappers, &graft_mappers/1)
    |> Workflow.add_cascade(:summarize, &summarize/1,
      deps: :mappers,
      queue: :external_content_ingestion,
      recorded: true
    )
  end
end

I also have an orchestration workflow which works like this:

Workflow.new()
|> Workflow.add_workflow(
  :ingestion_workflow,
  IngestionWorkflow.build(source_name, opts)
)
|> Workflow.add_workflow(
  :mapper_workflow,
  MapperWorkflow.build(source_name, opts),
  deps: [:ingestion_workflow]
)
|> Oban.insert_all()

Each of the sub-workflows work perfectly fine on their own, but when run from the orchestration, I get this error:

** (RuntimeError) module is not a worker: Oban.Pro.Workers.Context

I assume this has something to do with the fact that Oban.Pro.Workers.Context is a virtual module registered like: Job{worker: Oban.Pro.Workers.Context}

I can kinda work around this by grafting in the workflow, but that shouldn’t be necessary, and it would be better to be able to use the sub-workflows via add_workflow/4