ArchipelagoMW / Archipelago

Archipelago Multi-Game Randomizer and Server
https://archipelago.gg
Other
466 stars 621 forks source link

Bug: YAML Validation does not support aliases between documents #3248

Open Feldar99 opened 4 months ago

Feldar99 commented 4 months ago

What happened?

YAML files that contain anchors in one document which are referenced in further documents results in a validation error on https://archipelago.gg/check and a crash when used with the "Generate" option, but are valid YAML according to the official YAML linter https://www.yamllint.com/

I have attached an example file ExampleYAML.zip

What were the expected results?

I would expect the file to pass validation on https://archipelago.gg/check and generate a multiworld with 2 games each of which picks from the same options

Software

Website

eudaimonistic commented 4 months ago

I don't see this documented anywhere as an expected functionality. Why would this then be a bug?

I understand if this is a feature request, but this kind of aliasing is not explicitly supported.

Feldar99 commented 4 months ago

I'm having some trouble understanding the specification so I could be wrong, but the section about rejecting unidentified aliases says

"A well-formed character stream must match the BNF productions specified in the following chapters. Successful loading also requires that each alias shall refer to a previous node identified by the anchor. A YAML processor should reject ill-formed streams and unidentified aliases."

So it sounds like it's talking about the anchors existing in the stream not the document, and the section on streams says "A YAML stream consists of zero or more documents" This seems to be reinforced by it working in the official linter.

nicholassaylor commented 4 months ago

Looking into this issue, what you want to do cannot be done with how YAML files are processed. The anchor cannot be aliased across document as documents are completely independent of each other. Therefore, any anchor must be aliased before the next ---. In your example YAML, you attempt to alias after the anchor has "expired".

I tried using your YAML on the linter that you linked to and it also failed to recognize the alias, but returned that it is valid. Deleting the anchor without deleting the alias also returns this as true, which it clearly shouldn't. The linter is only checking if it is in the right format and not if the data is valid or not. Therefore, the linter shows that it is correct while properly parsing the data on the website shows it as invalid since the anchor does not exist for the alias on your second player.

nicholassaylor commented 1 month ago

An additional source using Python. I firmly believe that this is not a bug with Archipelago and is instead fundamental to the YAML format.