@@ -242,7 +242,7 @@ def get_pack_dependencies(client: demisto_client,
242
242
logging .warning (f"API request to fetch dependencies of pack '{ pack_id } ' has failed.\n "
243
243
f"Response code '{ ex .status } '\n Response: '{ ex .body } '\n Response Headers: '{ ex .headers } '" )
244
244
245
- elif isinstance (ex , ( HTTPError , HTTPWarning ) ):
245
+ elif isinstance (ex , HTTPError | HTTPWarning ):
246
246
logging .warning (f"Failed to perform HTTP request : { ex } " )
247
247
248
248
else :
@@ -349,11 +349,11 @@ def install_packs_private(client: demisto_client,
349
349
test_pack_path = test_pack_path )
350
350
351
351
352
- def get_error_ids (body : str ) -> set [ str ]:
352
+ def get_error_ids (body : str ) -> dict [ int , str ]:
353
353
with contextlib .suppress (json .JSONDecodeError ):
354
354
response_info = json .loads (body )
355
- return {error ["id" ] for error in response_info .get ("errors" , []) if "id" in error }
356
- return set ()
355
+ return {error ["id" ]: error . get ( "details" , "" ) for error in response_info .get ("errors" , []) if "id" in error }
356
+ return {}
357
357
358
358
359
359
def install_packs (client : demisto_client ,
@@ -417,10 +417,15 @@ def install_packs(client: demisto_client,
417
417
logging .error (f"Unable to install malformed packs: { malformed_ids } , retrying without them." )
418
418
packs_to_install = [pack for pack in packs_to_install if pack ['id' ] not in malformed_ids ]
419
419
420
- if (error_ids := get_error_ids (ex .body )) and WLM_TASK_FAILED_ERROR_CODE in error_ids :
421
- # If we got this error code, it means that the modeling rules are not valid, exiting install flow.
422
- raise Exception (f"Got [{ WLM_TASK_FAILED_ERROR_CODE } ] error code - Modeling rules and Dataset validations "
423
- f"failed. Please look at GCP logs to understand why it failed." ) from ex
420
+ error_ids = get_error_ids (ex .body )
421
+ if WLM_TASK_FAILED_ERROR_CODE in error_ids :
422
+ if "polling request failed for task ID" in error_ids [WLM_TASK_FAILED_ERROR_CODE ].lower ():
423
+ logging .error (f"Got { WLM_TASK_FAILED_ERROR_CODE } error code - polling request failed for task ID, "
424
+ f"retrying." )
425
+ else :
426
+ # If we got this error code, it means that the modeling rules are not valid, exiting install flow.
427
+ raise Exception (f"Got [{ WLM_TASK_FAILED_ERROR_CODE } ] error code - Modeling rules and Dataset validations "
428
+ f"failed. Please look at GCP logs to understand why it failed." ) from ex
424
429
425
430
if not attempt : # exhausted all attempts, understand what happened and exit.
426
431
if 'timeout awaiting response' in ex .body :
@@ -508,7 +513,7 @@ def search_pack_and_its_dependencies(client: demisto_client,
508
513
checked_packs = [pack_id ])
509
514
510
515
except Exception as ex :
511
- logging .error (f"Error: { ex } \n \n Stack trace:\n " + traceback .format_exc ())
516
+ logging .error (f"Error: { ex } \n \n Stack trace:\n { traceback .format_exc ()} " )
512
517
SUCCESS_FLAG = False
513
518
return
514
519
0 commit comments