-
Notifications
You must be signed in to change notification settings - Fork 837
Description
Which component is this bug for?
AlephAlpha Instrumentation
π Description
In the case that a tool call has an error, the instrumentation tries to attach an error code to the span
Lines 297 to 302 in 5bd93d9
| if hasattr(result, "isError") and result.isError: | |
| if len(result.content) > 0: | |
| span.set_status(Status(StatusCode.ERROR, f"{result.content[0].text}")) | |
| error_type = get_error_type(result.content[0].text) | |
| if error_type is not None: | |
| span.set_attribute(ERROR_TYPE, error_type) |
The error code is derived by looking into the error message for any number and convert it to HTTPStatus
Lines 401 to 408 in 5bd93d9
| def get_error_type(error_message): | |
| if not isinstance(error_message, str): | |
| return None | |
| match = re.search(r"\b(4\d{2}|5\d{2})\b", error_message) | |
| if match: | |
| num = int(match.group()) | |
| if 400 <= num <= 599: | |
| return HTTPStatus(num).name |
However, the HTTPStatus enum has a well-defined list of possible values (see them here). If the error message contains a random number, say, a port number like HTTPS 443, the HTTPStatus class will throw an error with the message 443 is not a valid HTTPStatus.
π Reproduction steps
Set up an MCP server where a tool call returns an error containing a number that is not part of the HTTPStatus enum.
π Expected behavior
The span should configure the error.type to be something like MCP tool Error. Parsing the first number found in the message as an HTTP status code is flaky and not representative of the error. If a network error occurs, the HTTP Instrumentation will report it.
π Actual Behavior with Screenshots
The tool call span wrongly reports the error as the HTTPStatus parsing error instead of the tool error.
π€ Python Version
No response
π Provide any additional context for the Bug.
No response
π Have you spent some time to check if this bug has been raised before?
- I checked and didn't find similar issue
Are you willing to submit PR?
None