Skip to content

Anchors do not work in recurring jobs yaml file #556

Open
@rbarrera87

Description

@rbarrera87

I am trying to setup my recurring jobs and I tried use anchors to do something like this:

production:
  the_recurring_job: &the_recurring_job
    queue: low
    class: TheRecurringJob
    schedule: "0 */2 * * *" # every 2h
    args:
      - arg1: "Some arg"
development:
  the_recurring_job: *the_recurring_job

I tried with:

production:
  the_recurring_job: &the_recurring_job
    queue: low
    class: TheRecurringJob
    schedule: "0 */2 * * *" # every 2h
    args:
      - arg1: "Some arg"
development:
  the_recurring_job: 
    <<: *the_recurring_job

But it didn't work either. When parsing this YAML to JSON I don't get any syntax error whatsoever, this is the output in JSON:

{
  "development": {
    "the_recurring_job": {
      "queue": "low", 
      "args": [
        {
          "arg1": "Some arg"
        }
      ], 
      "class": "TheRecurringJob", 
      "schedule": "0 */2 * * *"
    }
  }, 
  "production": {
    "the_recurring_job": {
      "queue": "low", 
      "args": [
        {
          "arg1": "Some arg"
        }
      ], 
      "class": "TheRecurringJob", 
      "schedule": "0 */2 * * *"
    }
  }
}

The error I am getting is this:

/usr/local/bundle/gems/psych-5.1.2/lib/psych/visitors/to_ruby.rb:432:in `visit_Psych_Nodes_Alias': Alias parsing was not enabled. To enable it, pass `aliases: true` to `Psych::load` or `Psych::safe_load`. (Psych::AliasesNotEnabled)

However this works when I do the same but without anchors:

production:
  the_recurring_job:
    queue: low
    class: TheRecurringJob
    schedule: "0 */2 * * *" # every 2h
    args:
      - arg1: "Some arg"
development:
  the_recurring_job:
    queue: low
    class: TheRecurringJob
    schedule: "0 */2 * * *" # every 2h
    args:
      - arg1: "Some arg"

Am I missing something or doing something wrong?
Rails version: Rails 7.1.5.1
Ruby version: ruby 3.3.8 (2025-04-09 revision b200bad6cd) [aarch64-linux]
Solid Queue version: solid_queue (1.1.4)

Thank you!

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