From 441e345b6b7f3c873222b025ca28f0bebb409853 Mon Sep 17 00:00:00 2001 From: Pallab Pain Date: Thu, 1 Feb 2024 18:03:59 +0530 Subject: [PATCH] fix(apply): raises error when a metadata has no name When a resource manifest has no name in metadata, it throws a KeyError. This commit fixes the error reporting to state the issue more explicitly. Wrike Ticket: https://www.wrike.com/open.htm?id=1238536095 --- riocli/apply/parse.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/riocli/apply/parse.py b/riocli/apply/parse.py index c7399cb0..ab5d2230 100644 --- a/riocli/apply/parse.py +++ b/riocli/apply/parse.py @@ -450,6 +450,9 @@ def _get_attr(obj, accept_keys): @staticmethod def _get_object_key(obj: dict) -> str: kind = obj.get('kind').lower() - name_or_guid = obj['metadata']['name'] + name_or_guid = obj.get('metadata', {}).get('name') + + if not name_or_guid: + raise ValueError('[kind:{}] name is required.'.format(kind)) return '{}:{}'.format(kind, name_or_guid)