From a58e616769528bc8b3054578b2a793949c200a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 29 Aug 2018 11:22:39 +0200 Subject: [PATCH] Markdown validator: gracefully handle partial document validation Validation of partial documents can happen when validating an update. Missing data is fine then. --- pillar/api/custom_field_validation.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pillar/api/custom_field_validation.py b/pillar/api/custom_field_validation.py index 0cd578bc..df52dfef 100644 --- a/pillar/api/custom_field_validation.py +++ b/pillar/api/custom_field_validation.py @@ -191,7 +191,11 @@ class ValidateCustomFields(Validator): # Find this field inside the original document my_subdoc = self._subdoc_in_real_document() if my_subdoc is None: - self._error(field, f'unable to find sub-document for path {self.document_path}') + # If self.update==True we are validating an update document, which + # may not contain all fields, so then a missing field is fine. + if not self.update: + self._error(field, f'validator_markdown: unable to find sub-document ' + f'for path {self.document_path}') return my_log.debug('validating field %r with value %r', field, value)