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

Better error type on connection timeout #10

Open
feixieliz opened this issue Dec 30, 2024 · 0 comments
Open

Better error type on connection timeout #10

feixieliz opened this issue Dec 30, 2024 · 0 comments

Comments

@feixieliz
Copy link

Problem Background

When running client.push_trace(request), got the error invariant_sdk.types.exceptions.InvariantError: Connection error when calling method: POST for path: /api/v1/push/trace. The complete traceback of errors is given as follows:

Traceback:
TimeoutError: The write operation timed out
During handling of the above exception, another exception occurred:
urllib3.exceptions.ProtocolError: ('Connection aborted.', TimeoutError('The write operation timed out'))
......
During handling of the above exception, another exception occurred:
requests.exceptions.ConnectionError: ('Connection aborted.', TimeoutError('The write operation timed out'))
......
The above exception was the direct cause of the following exception:
invariant_sdk.types.exceptions.InvariantError: Connection error when calling method: POST for path: /api/v1/push/trace.

The connection to the URI was in fact successful but the subsequent write operation timed out because the trace to be pushed is too large due to infinite loops in the response of LLM. But the InvariantError message suggested a connection error which was misleading in the beginning of debugging.

Code

In client.py, the relevant error is handled as below:

except requests.ReadTimeout as e:
raise InvariantAPITimeoutError(
f"Timeout when calling method: {method} for path: {pathname}."
) from e
except (requests.ConnectionError, requests.ConnectTimeout) as e:
raise InvariantError(
f"Connection error when calling method: {method} for path: {pathname}."
) from e

Suggestion

In my opinion, it makes more sense to raise InvariantAPITimeoutError when it is triggered by requests.ConnectTimeout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant