Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EWSv2, EWSo365: Skip-on-error skips all exceptions #37201

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions Packs/MicrosoftExchangeOnPremise/Integrations/EWSv2/EWSv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,16 +1333,17 @@ def fetch_emails_as_incidents(account_email, folder_name, skip_unparsable_emails

if len(incidents) >= MAX_FETCH:
break
except (UnicodeEncodeError, UnicodeDecodeError, IndexError) as e:
if skip_unparsable_emails:
error_msg = (
"Encountered email parsing issue while fetching. "
f"Skipping item with message id: {item.message_id if item.message_id else ''}"
)
demisto.debug(error_msg + f", Error: {str(e)}")
demisto.updateModuleHealth(error_msg, is_error=False)
else:
raise e
except Exception as e:
if not skip_unparsable_emails: # default is to raise and exception and fail the command
raise

# when the skip param is `True`, we log the exceptions and move on instead of failing the whole fetch
error_msg = (
"Encountered email parsing issue while fetching. "
f"Skipping item with message id: {item.message_id or '<error parsing message_id>'}"
)
demisto.debug(f"{error_msg}, Error: {str(e)} {traceback.format_exc()}")
demisto.updateModuleHealth(error_msg, is_error=False)

demisto.debug(f'EWS V2 - ending fetch - got {len(incidents)} incidents.')
last_fetch_time = last_run.get(LAST_RUN_TIME)
Expand Down
6 changes: 6 additions & 0 deletions Packs/MicrosoftExchangeOnPremise/ReleaseNotes/2_1_16.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Integrations

##### EWS v2

Extended the `Skip Unparsable Emails` parameter to handle additional error cases.
2 changes: 1 addition & 1 deletion Packs/MicrosoftExchangeOnPremise/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Microsoft Exchange On-Premise",
"description": "Exchange Web Services",
"support": "xsoar",
"currentVersion": "2.1.15",
"currentVersion": "2.1.16",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down
21 changes: 11 additions & 10 deletions Packs/MicrosoftExchangeOnline/Integrations/EWSO365/EWSO365.py
Original file line number Diff line number Diff line change
Expand Up @@ -2470,16 +2470,17 @@ def fetch_emails_as_incidents(client: EWSClient, last_run, incident_filter, skip

if len(incidents) >= client.max_fetch:
break
except (UnicodeEncodeError, UnicodeDecodeError, IndexError) as e:
if skip_unparsable_emails:
error_msg = (
"Encountered email parsing issue while fetching. "
f"Skipping item with message id: {item.message_id if item.message_id else ''}"
)
demisto.debug(error_msg + f", Error: {str(e)}")
demisto.updateModuleHealth(error_msg, is_error=False)
else:
raise e
except Exception as e:
if not skip_unparsable_emails: # default is to raise and exception and fail the command
raise

# when the skip param is `True`, we log the exceptions and move on instead of failing the whole fetch
error_msg = (
"Encountered email parsing issue while fetching. "
f"Skipping item with message id: {item.message_id or '<error parsing message_id>'}"
)
demisto.debug(f"{error_msg}, Error: {str(e)} {traceback.format_exc()}")
demisto.updateModuleHealth(error_msg, is_error=False)

demisto.debug(f'{APP_NAME} - ending fetch - got {len(incidents)} incidents.')

Expand Down
6 changes: 6 additions & 0 deletions Packs/MicrosoftExchangeOnline/ReleaseNotes/1_5_16.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Integrations

##### EWS O365

Extended the `Skip Unparsable Emails` parameter to handle additional error cases.
2 changes: 1 addition & 1 deletion Packs/MicrosoftExchangeOnline/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Microsoft Exchange Online",
"description": "Exchange Online and Office 365 (mail)",
"support": "xsoar",
"currentVersion": "1.5.15",
"currentVersion": "1.5.16",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down
Loading