Skip to content

Anchors do not work in recurring jobs yaml file #556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rbarrera87 opened this issue Apr 25, 2025 · 1 comment
Open

Anchors do not work in recurring jobs yaml file #556

rbarrera87 opened this issue Apr 25, 2025 · 1 comment

Comments

@rbarrera87
Copy link

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!

@mrj
Copy link

mrj commented Apr 30, 2025

Try

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

development:
    <<: *the_recurring_job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants