Conversation
| error_message = json.dumps(err.response.json()) | ||
| except: # noqa: E722 | ||
| pass | ||
|
|
||
| try: | ||
| if error_message == '': | ||
| error_message = err.response.text | ||
| except: # noqa: E722 | ||
| pass | ||
|
|
||
| raise TextualServerBadRequest(error_message) |
There was a problem hiding this comment.
Bug: http_post raises TextualServerBadRequest, which is not caught by requests.exceptions.HTTPError in callers.
Severity: CRITICAL | Confidence: High
🔍 Detailed Analysis
The http_post method now raises TextualServerBadRequest for 400 errors. However, calling methods like send_redact_request and send_redact_bulk_request are designed to catch requests.exceptions.HTTPError. Since TextualServerBadRequest does not inherit from requests.exceptions.HTTPError, these exceptions will not be caught by the existing try...except blocks, causing the application to crash with an unhandled exception when a 400 error occurs.
💡 Suggested Fix
Ensure TextualServerBadRequest inherits from requests.exceptions.HTTPError, or modify the calling except blocks to catch TextualServerBadRequest specifically.
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: tonic_textual/classes/httpclient.py#L205-L218
Potential issue: The `http_post` method now raises `TextualServerBadRequest` for 400
errors. However, calling methods like `send_redact_request` and
`send_redact_bulk_request` are designed to catch `requests.exceptions.HTTPError`. Since
`TextualServerBadRequest` does not inherit from `requests.exceptions.HTTPError`, these
exceptions will not be caught by the existing `try...except` blocks, causing the
application to crash with an unhandled exception when a 400 error occurs.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 5294566
There was a problem hiding this comment.
This is fine. It is still caught by requests.exceptions.RequestException
No description provided.