Skip to content

Commit

Permalink
RTIR - handle '409 Syntax Error' (#38777)
Browse files Browse the repository at this point in the history
* handle '409 Syntax Error'

* Update Packs/RTIR/ReleaseNotes/1_0_24.md

Co-authored-by: israelpoli <[email protected]>

---------

Co-authored-by: israelpoli <[email protected]>
  • Loading branch information
yedidyacohenpalo and israelpoli authored Feb 26, 2025
1 parent e8e2337 commit 37527ac
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Packs/RTIR/Integrations/RTIR/RTIR.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ def create_ticket():
raw_ticket_res = create_ticket_attachments_request(encoded, files_data)
else:
raw_ticket_res = create_ticket_request(encoded)

if "409 Syntax Error" in raw_ticket_res.text:
raise DemistoException(f"Ticket creation failed. Response: {raw_ticket_res.text}")

ticket_id = re.findall(r'\d+', raw_ticket_res.text)[-1]
demisto.debug(f"got ticket with id: {ticket_id}")
if ticket_id == -1:
Expand Down
25 changes: 25 additions & 0 deletions Packs/RTIR/Integrations/RTIR/RTIR_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,28 @@ def test_edit_ticket(mocker):
edit_ticket()
except Exception as ex:
assert ex.message == 'No arguments were given to edit the ticket.'


def test_create_ticket_409_failure(mocker):
args = {
'queue': 'test',
'subject': 'Test Ticket',
'requestor': '[email protected]',
'priority': 'High',
'text': 'This is a test ticket',
}

mock_response = DotDict({
'status_code': 200,
'text': 'RT/5.0.3 409 Syntax Error\nTicket creation failed'
})

mocker.patch.object(demisto, 'args', return_value=args)
mocker.patch('RTIR.create_ticket_request', return_value=mock_response)

from RTIR import create_ticket
with pytest.raises(DemistoException) as e:
create_ticket()

assert "Ticket creation failed" in str(e.value)
assert "RT/5.0.3 409 Syntax Error" in str(e.value)
6 changes: 6 additions & 0 deletions Packs/RTIR/ReleaseNotes/1_0_24.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Integrations

##### RTIR

- Fixed an issue where the `rtir-create-ticket` command did not raise an error when the ticket was not created due to a syntax error.
2 changes: 1 addition & 1 deletion Packs/RTIR/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "RTIR",
"description": "Request Tracker for Incident Response is a ticketing system which provides pre-configured queues and workflows designed for incident response teams.",
"support": "xsoar",
"currentVersion": "1.0.23",
"currentVersion": "1.0.24",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit 37527ac

Please sign in to comment.