Skip to content

validate_yaml: Diagnostic improvements - #1593

Merged
bhcopeland merged 2 commits into
kernelci:mainfrom
broonie:validate-logging
Sep 8, 2026
Merged

validate_yaml: Diagnostic improvements#1593
bhcopeland merged 2 commits into
kernelci:mainfrom
broonie:validate-logging

Conversation

@broonie

@broonie broonie commented Sep 3, 2026

Copy link
Copy Markdown
Member

A couple of fairly trivial usability improvements for validate_yaml.py.

  • validate_yaml: Handle and print exceptions
  • validate_yaml: Also handle ValueError from recursive_merge()

Comment thread tests/validate_yaml.py
Comment thread tests/validate_yaml.py Outdated
Comment thread tests/validate_yaml.py
Comment thread tests/validate_yaml.py Outdated
Validation failures are reported with exceptions but currently we do not
handle them, instead relying on Python's default unhandled exception
behaviour. As well as being verbose this is actively unhelpful for
exceptions like:

      raise ValueError(
          f"Key {k} has different values in both dictionaries"
      )

where the source for the raise is displayed without any interpolation of
the value, making it hard to understand what validation failed. Instead
handle exceptions by printing them, this isn't terribly sophisticated but
still a step forward in usability.  Only do this for exceptions the the
program and it's libraries are currently known to generate in order to
preserve some of the backtrace experience for users if anything new
happens.

Signed-off-by: Mark Brown <broonie@kernel.org>
recursive_merge() can raise ValueError as well as the currently handled
YAMLError, handle both so we can tell the user which file we were trying
to parse when we ran into trouble. It's less useful than it might be since
it doesn't say which file had the original value but we've lost that
information by the time we run into trouble.

Signed-off-by: Mark Brown <broonie@kernel.org>
@bhcopeland
bhcopeland added this pull request to the merge queue Sep 8, 2026
Merged via the queue into kernelci:main with commit e41bba6 Sep 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants