Skip to content

Commit

Permalink
fix(agent): Throw traceback obtained from agent
Browse files Browse the repository at this point in the history
  • Loading branch information
balamurali27 committed Jan 2, 2025
1 parent 62beb44 commit 3eae531
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions press/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import frappe
import requests
from frappe.utils.password import get_decrypted_password
from requests.exceptions import HTTPError

from press.utils import get_mariadb_root_password, log_error, sanitize_config

Expand Down Expand Up @@ -781,8 +782,17 @@ def request(self, method, path, data=None, files=None, agent_job=None, raises=Tr
json_response = None
try:
json_response = self.response.json()
if raises:
self.response.raise_for_status()
if raises and self.response.status_code >= 400:
output = (

Check warning on line 786 in press/agent.py

View check run for this annotation

Codecov / codecov/patch

press/agent.py#L786

Added line #L786 was not covered by tests
f"""{json_response.get("output")}
{json_response.get("traceback")}"""
or json.dumps(json_response, indent=2, sort_keys=True)
)
raise HTTPError(

Check warning on line 792 in press/agent.py

View check run for this annotation

Codecov / codecov/patch

press/agent.py#L792

Added line #L792 was not covered by tests
f"{self.response.status_code} {self.response.reason} {output}",
response=self.response,
)
return json_response
except Exception:
self.handle_request_failure(agent_job, self.response)
Expand Down

0 comments on commit 3eae531

Please sign in to comment.