@@ -2227,6 +2227,7 @@ def search_datastore_category(self, input_list, key, category):
2227
2227
2228
2228
url = f"{ self .url } /api/v2/datastore?bulk=true&execution_id={ self .current_execution_id } &authorization={ self .authorization } "
2229
2229
response = requests .post (url , json = data , verify = False )
2230
+
2230
2231
if response .status_code != 200 :
2231
2232
returnvalue ["reason" ] = "Failed to check datastore key exists"
2232
2233
returnvalue ["details" ] = response .text
@@ -2240,16 +2241,20 @@ def search_datastore_category(self, input_list, key, category):
2240
2241
return response .text
2241
2242
2242
2243
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
2244
2248
2249
+ not_found_keys = []
2245
2250
returnvalue ["success" ] = True
2246
2251
for datastore_item in input_list :
2247
2252
found = False
2248
2253
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 ]) :
2250
2255
continue
2251
2256
2252
- if existing_item ["existed" ]:
2257
+ if existing_item ["existed" ] == True :
2253
2258
returnvalue ["exists" ].append (datastore_item )
2254
2259
else :
2255
2260
returnvalue ["new" ].append (datastore_item )
@@ -2259,7 +2264,12 @@ def search_datastore_category(self, input_list, key, category):
2259
2264
2260
2265
if not found :
2261
2266
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."
2263
2273
2264
2274
return json .dumps (returnvalue , indent = 4 )
2265
2275
0 commit comments