Skip to content

Commit e90af5e

Browse files
fix resolve incident teardown function
1 parent 4fbd044 commit e90af5e

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/browsergym/workarena/tasks/incident.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@ class ResolveIncidentTask(ServiceNowIncidentTask):
270270
def __init__(self, *args, **kwargs):
271271
super().__init__(*args, **kwargs)
272272

273-
self.initial_incident_close_code = self._get_initial_incident_close_code()
273+
self._get_initial_incident_info()
274274

275-
def _get_initial_incident_close_code(self):
275+
def _get_initial_incident_info(self):
276276

277277
incident_number = self.config["incident_number"]
278278

@@ -291,8 +291,8 @@ def _get_initial_incident_close_code(self):
291291
if not result:
292292
raise ValueError(f"Incident {incident_number} not found")
293293

294-
return result[0]["close_code"]
295-
294+
self.incident_sys_id = result[0]["sys_id"]
295+
self.initial_incident_close_code = result[0]["close_code"]
296296

297297
def all_configs(self):
298298
return json.load(open(RESOLVE_INCIDENT_CONFIG_PATH))
@@ -352,17 +352,14 @@ def teardown(self) -> None:
352352
# reset the close code to the initial value
353353
if self.initial_incident_close_code is not None and self.config["close_code"] != self.initial_incident_close_code:
354354
try:
355-
table_api_call(
356-
instance=self.instance,
357-
table="incident",
358-
params={
359-
"sysparm_query": f"number={self.config['incident_number']}",
360-
},
361-
data={
355+
requests.patch(
356+
f"{self.instance.snow_url}/api/now/table/incident/{self.incident_sys_id}",
357+
auth=self.instance.snow_credentials,
358+
headers={"Accept": "application/json"},
359+
json={
362360
"close_code": self.initial_incident_close_code,
363-
"close_notes": "", # empty close notes
361+
"close_notes": "",
364362
},
365-
method="PUT",
366363
)
367364
except HTTPError:
368365
# sys_id was stored in local storage (for submitted)

0 commit comments

Comments
 (0)