Browse Source

Fix logging when "Duplicate document exists" error occurs

Currently validation fails with "KeyError: 'schema'",
which makes it hard to determine a root cause of error.

Change-Id: Ifd40faf485578cc0a133e17650f8df6758a6c8ae
changes/41/614641/2
Evgeny L 8 months ago
parent
commit
ec8bad3bf4
1 changed files with 12 additions and 11 deletions
  1. 12
    11
      deckhand/engine/layering.py

+ 12
- 11
deckhand/engine/layering.py View File

@@ -329,17 +329,18 @@ class DocumentLayering(object):
329 329
         error_list = []
330 330
         for result in results:
331 331
             for e in result['errors']:
332
-                LOG.error('Document [%s, %s] %s failed with pre-validation '
333
-                          'error: %s.', e['schema'], e['layer'], e['name'],
334
-                          e['message'])
335
-                error_list.append(
336
-                    ValidationMessage(
337
-                        message=e['message'],
338
-                        doc_schema=e['schema'],
339
-                        doc_name=e['name'],
340
-                        doc_layer=e['layer']
341
-                    )
342
-                )
332
+                for d in e['documents']:
333
+                    LOG.error('Document [%s, %s] %s failed with '
334
+                              'pre-validation error: "%s". Diagnostic: "%s".',
335
+                              d['schema'], d['layer'], d['name'],
336
+                              e['message'], e['diagnostic'])
337
+
338
+                    error_list.append(
339
+                        ValidationMessage(
340
+                            message=e['message'],
341
+                            doc_schema=d['schema'],
342
+                            doc_name=d['name'],
343
+                            doc_layer=d['layer']))
343 344
 
344 345
         if error_list:
345 346
             raise errors.InvalidDocumentFormat(error_list=error_list)

Loading…
Cancel
Save