Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message for module validation #19501

Merged
merged 1 commit into from
Dec 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion test/sanity/validate-modules/validate-modules
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ from module_args import get_argument_spec
from schema import doc_schema, option_schema

from utils import CaptureStd
from voluptuous.humanize import humanize_error

import yaml
import yaml.reader
Expand Down Expand Up @@ -373,6 +374,8 @@ class ModuleValidator(Validator):
try:
doc_schema(doc)
except Exception as e:
for error in e.errors:
error.data = doc
errors.extend(e.errors)

options = doc.get('options', {})
Expand All @@ -382,12 +385,13 @@ class ModuleValidator(Validator):
except Exception as e:
for error in e.errors:
error.path[:0] = ['options', key]
error.data = option
errors.extend(e.errors)

for error in errors:
path = [str(p) for p in error.path]
self.errors.append('DOCUMENTATION.%s: %s' %
('.'.join(path), error.error_message))
('.'.join(path), humanize_error(error.data, error)))

def _validate_docs(self):
doc_info = self._get_docs()
Expand Down