Skip to content

Commit 60d099f

Browse files
committed
kernelci: api: helper: don't crash when adding artifacts to node
Nodes are created with `'artifacts': null`, meaning calling `update()` could lead to an uncaught exception, and therefore a crash. Avoid this situation by calling `update()` only when this key exists and yields a non-None value. Signed-off-by: Arnaud Ferraris <[email protected]>
1 parent 9df5d25 commit 60d099f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kernelci/api/helper.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,14 @@ def submit_results(self, results, root):
557557
root_from_db = self.api.node.get(root['id'])
558558
root_node = merge(root_from_db, root)
559559
root_node = root.copy()
560+
# TODO: we should also go through other potential fields and copy
561+
# them over. Maybe even just: root_node = merge(results['node'], root)
560562
root_node['result'] = results['node']['result']
561563
root_node['state'] = results['node'].get('state', 'done')
562-
root_node['artifacts'].update(results['node']['artifacts'])
564+
if root_node.get('artifacts'):
565+
root_node['artifacts'].update(results['node']['artifacts'])
566+
else:
567+
root_node['artifacts'] = results['node']['artifacts']
563568
root_node['data'].update(results['node'].get('data', {}))
564569
root_node['processed_by_kcidb_bridge'] = False
565570
if 'holdoff' in results['node']:

0 commit comments

Comments
 (0)