Cog-Creators / Red-DiscordBot

A multi-function Discord bot

Home Page:https://docs.discord.red

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Permissions YAML validation incorrect feedback

Flame442 opened this issue · comments

Running [p]permissions acl setserver (or setglobal) with the valid YAML data below causes the message Your YAML file did not match the schema: Top-level keys must be either COG or COMMAND. to appear.

COMMAND:
    addrole:
        55555555555:

The error is the fact that the snowflake does not have an explicit true/false value associated with it, so it is implicitly null. The same error happens if the snowflake is explicitly null, or is any other non-boolean value.

The logic for validating raw YAML inputs seems to not be selecting the correct error message for what is actually wrong with the schema.

YAML_SCHEMA = Schema(
Or(
{
UseOptional(COMMAND): Or(
{
Or(str, int): Or(
{
Or(int, "default"): And(
bool, error=_("Rules must be either `true` or `false`.")
)
},
{},
error=_("Keys under command names must be IDs (numbers) or `default`."),
)
},
{},
error=_("Keys under `COMMAND` must be command names (strings)."),
),
UseOptional(COG): Or(
{
Or(str, int): Or(
{
Or(int, "default"): And(
bool, error=_("Rules must be either `true` or `false`.")
)
},
{},
error=_("Keys under cog names must be IDs or `default`."),
)
},
{},
error=_("Keys under `COG` must be cog names (strings)."),
),
},
{},
error=_("Top-level keys must be either `COG` or `COMMAND`."),
)
)

Duplicate of #3185, feel free to comment with your example there but the issue comes down to the same thing.