From b81db1383a53c8739554e6bb14d8c869fbe5c1f6 Mon Sep 17 00:00:00 2001 From: Aditya Pandey <147182147+AdityaPandeyCN@users.noreply.github.com> Date: Thu, 12 Dec 2024 22:04:39 +0530 Subject: [PATCH] :bug: Fix for #478 KeyError: 'latestVersion' (#518) * removing the keyerror Signed-off-by: AdityaBITMESRA * Fixing up trunk check formatting error Signed-off-by: Shawn Hurley --------- Signed-off-by: AdityaBITMESRA Signed-off-by: Shawn Hurley Co-authored-by: Shawn Hurley --- .../agent/dependency_agent/util.py | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/kai/reactive_codeplanner/agent/dependency_agent/util.py b/kai/reactive_codeplanner/agent/dependency_agent/util.py index f5729e2e..1ef5683b 100644 --- a/kai/reactive_codeplanner/agent/dependency_agent/util.py +++ b/kai/reactive_codeplanner/agent/dependency_agent/util.py @@ -26,17 +26,23 @@ def search_fqdn_query(query: str) -> Optional[FQDNResponse] | list[FQDNResponse] ### context. all_found_deps = [] for d in docs: - all_found_deps.append( - FQDNResponse( - artifact_id=d["a"], group_id=d["g"], version=d["latestVersion"] + if "latestVersion" in d: + all_found_deps.append( + FQDNResponse( + artifact_id=d["a"], group_id=d["g"], version=d["latestVersion"] + ) ) - ) - return all_found_deps + return all_found_deps if all_found_deps else None else: doc = docs[0] - return FQDNResponse( - artifact_id=doc["a"], group_id=doc["g"], version=doc["latestVersion"] - ) + + if "latestVersion" in doc: + + return FQDNResponse( + artifact_id=doc["a"], group_id=doc["g"], version=doc["latestVersion"] + ) + + return None def search_fqdn(code: str) -> Optional[FQDNResponse] | list[FQDNResponse]: