urlwatch icon indicating copy to clipboard operation
urlwatch copied to clipboard

YAML Anchors/Aliases not working

Open Knuschberkeks opened this issue 7 months ago • 3 comments

I'm not even sure if this is an issue with urlwatch or not, but: I have a set of jobs that I need to apply the same set of filters to. So i tried this:

name: "test job 1"
url: "example.com"
filter: &testfilters
  - filter1
  - filter2
---
name:: "test job 2"
url: "example.net"
filter: *testfilters

but when I save I get the error found undefined alias 'testfilters'

Knuschberkeks avatar Dec 31 '23 20:12 Knuschberkeks

Huh, I didn't even know those were a thing. We use yaml.SafeLoader (from PyYAML) for loading, can you try playing around with some other class in lib/urlwatch/storage.py?

thp avatar Jan 01 '24 20:01 thp

I'm really sorry but I don't really understand what that means... I'm not really a programmer.

Knuschberkeks avatar Jan 03 '24 09:01 Knuschberkeks

This is actually because they are different yaml documents. YAML does not allow anchors/references between documents, even if they are in the same file.

See: https://yaml.org/spec/1.2-old/spec.html#id2800132

Jamstah avatar Jan 17 '24 14:01 Jamstah

Closing this as "works as intended" for now.

thp avatar Apr 24 '24 19:04 thp