bitops icon indicating copy to clipboard operation
bitops copied to clipboard

bitops.config.yaml should be validated against the schema

Open arm4b opened this issue 2 years ago • 2 comments

Following the https://github.com/bitovi/bitops/pull/236 While having a config schema, looks like we don't do a proper validation for plugins config bitops.config.yaml.

Example nonsense yaml config:

bitops:
  a: b
  c: d
  fail_fast: true
  d:
    e
  logging:
    level: foo
    color:
      enabled: maybe

Should be validated properly against the config schema and error in every place with a clear error message as users will naturally create typos, wrong copy-paste or invalid configs and the error messages they might get now are confusing.

arm4b avatar Aug 01 '22 13:08 arm4b

In addition to this we should move the defaults for these config values into the schema and out of the core.

PhillypHenning avatar Aug 01 '22 14:08 PhillypHenning

For python schema/config validation the conventional choices are:

  • https://json-schema.org/ is a commonly used standard across the projects irrespective of programming language
    • https://github.com/python-jsonschema/jsonschema 4K ⭐️
    • Example: https://stackoverflow.com/a/22231372/4533625
    • Example schema: https://github.com/StackStorm/st2/blob/master/st2common/st2common/util/schema/action_output_schema.json
  • Python schema lib is another alternative
    • https://github.com/keleshev/schema 3K ⭐️
    • Examples: https://www.andrewvillazon.com/validate-yaml-python-schema/

arm4b avatar Oct 17 '22 12:10 arm4b