Archipelago icon indicating copy to clipboard operation
Archipelago copied to clipboard

Core: warn if a yaml is empty

Open Zannick opened this issue 1 year ago • 1 comments

What is this fixing or adding?

--- marks the start of a yaml document which lets us put multiple yamls in one file, but if it's accidentally put at the end of the file (or twice in a row or anything), that yaml document will be empty, aka None. This throws an exception that doesn't clearly identify the file:

Uncaught exception
Traceback (most recent call last):
  File "c:\Users\bswolf\Documents\GitHub\Archipelago\Generate.py", line 529, in <module>
    erargs, seed = main()
                   ^^^^^^
  File "c:\Users\bswolf\Documents\GitHub\Archipelago\Generate.py", line 127, in main
    f"{get_choice('description', yaml, 'No description specified')}")
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\bswolf\Documents\GitHub\Archipelago\Generate.py", line 260, in get_choice
    if option not in root:
       ^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

Rather than write a new exception to specify the file, we can simply issue a warning and continue:

P72 Weights: Zannick Psy.yaml >> Plain Psychonauts
Ignoring empty yaml block in Zannick Psy.yaml
P73 Weights: Zillion.yaml >> Default Zillion Template

How was this tested?

Manually.

Zannick avatar Oct 29 '24 05:10 Zannick

I did not test webhost whatsoever

Exempt-Medic avatar Oct 29 '24 13:10 Exempt-Medic

I suppose I should make it happen the same on WebHost.

Zannick avatar Nov 04 '24 04:11 Zannick

I did not add a log to WebHost since it won't be shown to the user. Tested on WebHost with Clique, successfully generated.

Zannick avatar Nov 09 '24 18:11 Zannick

Webhost correctly ignores an empty YAML, however, local generation now crashes when one exists, with a different exception

image

My YAML file was a default CV64 YAML with an empty document appended at the end.

nicholassaylor avatar Nov 10 '24 03:11 nicholassaylor

I have no idea why that was different than before, but I've made it so that we don't keep the empty objects around, rather than add if yaml is not None everywhere.

Zannick avatar Nov 10 '24 06:11 Zannick