cancel
Showing results for 
Search instead for 
Did you mean: 

Script validator tests too strictly for the expected YAML structure

Rukt
Community Member

I sent the below as feedback, but I realise that rarely gets acknowledged. I thought a conversation here might prove more fruitful!

At present, the script editor supports YAML's anchors and aliases. These are useful for defining re-usable blocks (such as a condition common to multiple starters) and "pseudo-variables".

I feel that it would be useful to be able to define such anchors at the top of the file (e.g., under a "definitions" section), rather than requiring that they be defined where they are first used. This would be a cleaner pattern for maintenance, and better allow "templating" of automations.

At present, any unrecognised keys (or, keys used where they are not expected in the structure) cause a validation error.

I'd like to see Google consider:
* extend the "metadata" mapping with a "definitions" key or similar, containing arbitrary mappings under which a user might define anchors
* permit the script to be saved and run, even when there are unexpected fields in the structure (a sort of "ignore warnings" mode for low-criticality issues)

1 REPLY 1

thismarkjohnson
Community Member

That’s a solid suggestion—having a top-level definitions section for anchors would definitely make scripts cleaner and easier to maintain. The strict validation is helpful for errors, but an “ignore warnings” or flexible mode for non-critical keys would be a great addition. Worth submitting through official feedback too, as that’s where feature requests are tracked.