Skip to content

Commit

Permalink
schema: print link to online documentation on validation error
Browse files Browse the repository at this point in the history
As the schema itself as a documentation on which config elements are
supported has proven to not be very helpful, we now directly print a
link to the online documentation of the project configuration on error.

While this somehow links kas to its online representation, this pattern
became common practice for many OSS projects.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
  • Loading branch information
fmoessbauer authored and jan-kiszka committed Jan 30, 2025
1 parent a4792e2 commit 4ea0f61
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kas/includehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@
from jsonschema.validators import validator_for

from .kasusererror import KasUserError
from . import __file_version__, __compatible_file_version__
from . import __file_version__, __compatible_file_version__, __version__
from . import CONFIGSCHEMA

__license__ = 'MIT'
__copyright__ = 'Copyright (c) Siemens AG, 2017-2021'

SOURCE_DIR_OVERRIDE_KEY = '_source_dir'
SOURCE_DIR_HOST_OVERRIDE_KEY = '_source_dir_host'
PROJECT_CONFIG_URL = f'https://kas.readthedocs.io/en/{__version__}/' \
'userguide/project-configuration.html'


class LoadConfigException(KasUserError):
Expand Down Expand Up @@ -78,6 +80,8 @@ def load_config(filename):
for error in sorted(validator.iter_errors(config), key=str):
validation_error = True
logging.error('Config file validation Error:\n%s', error.message)
logging.error('For a list of supported configuration elements, see %s',
PROJECT_CONFIG_URL)

if validation_error:
logging.debug('Validation against this schema failed:\n%s',
Expand Down

0 comments on commit 4ea0f61

Please # to comment.