@@ -2227,6 +2227,7 @@ def search_datastore_category(self, input_list, key, category):
22272227
22282228 url = f"{ self .url } /api/v2/datastore?bulk=true&execution_id={ self .current_execution_id } &authorization={ self .authorization } "
22292229 response = requests .post (url , json = data , verify = False )
2230+
22302231 if response .status_code != 200 :
22312232 returnvalue ["reason" ] = "Failed to check datastore key exists"
22322233 returnvalue ["details" ] = response .text
@@ -2240,16 +2241,20 @@ def search_datastore_category(self, input_list, key, category):
22402241 return response .text
22412242
22422243 if "keys_existed" not in data :
2243- return data
2244+ returnvalue ["error" ] = "Invalid response from backend during bulk update of keys"
2245+ returnvalue ["details" ] = data
2246+
2247+ return returnvalue
22442248
2249+ not_found_keys = []
22452250 returnvalue ["success" ] = True
22462251 for datastore_item in input_list :
22472252 found = False
22482253 for existing_item in data ["keys_existed" ]:
2249- if existing_item ["key" ] != datastore_item [key ]:
2254+ if str ( existing_item ["key" ]) != str ( datastore_item [key ]) :
22502255 continue
22512256
2252- if existing_item ["existed" ]:
2257+ if existing_item ["existed" ] == True :
22532258 returnvalue ["exists" ].append (datastore_item )
22542259 else :
22552260 returnvalue ["new" ].append (datastore_item )
@@ -2259,7 +2264,12 @@ def search_datastore_category(self, input_list, key, category):
22592264
22602265 if not found :
22612266 print ("[ERROR][%s] Key %s not found in datastore response, adding as new" % (self .current_execution_id , datastore_item [key ]))
2262- returnvalue ["new" ].append (datastore_item )
2267+ #returnvalue["new"].append(datastore_item)
2268+ not_found_keys .append (datastore_item [key ])
2269+
2270+ if len (not_found_keys ) > 0 :
2271+ returnvalue ["unhandled_keys" ] = not_found_keys
2272+ returnvalue [
"reason" ]
= "Something went wrong updating the unhandled_keys. Please contact [email protected] if this persists." 22632273
22642274 return json .dumps (returnvalue , indent = 4 )
22652275
0 commit comments