Skip to content

Conversation

@cristipufu
Copy link
Member

@cristipufu cristipufu commented Jul 3, 2025

Summary

This PR refactors error handling in the session and runtime modules to leverage Python 3.11 exception groups, tightens shutdown logic, and updates package metadata.

  • Use asyncio.wait_for with a timeout when cancelling the session consumer task and update exception catches to handle asyncio.TimeoutError
  • Consolidate exception logging to use except* Exception and add specific handling for HTTPStatusError
  • Bump package version to 0.0.93, require Python >=3.11, and update dependency versions

Development Package

  • Add this package as a dependency in your pyproject.toml:
[project]
dependencies = [
  # Exact version:
  "uipath-mcp==0.0.93.dev1001140019",

  # Any version from PR
  "uipath-mcp>=0.0.93.dev1001140000,<0.0.93.dev1001150000"
]

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true

[tool.uv.sources]
uipath-mcp = { index = "testpypi" }

@cristipufu cristipufu self-assigned this Jul 3, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors error handling in the session and runtime modules to leverage Python 3.11 exception groups, tightens shutdown logic, and updates package metadata.

  • Use asyncio.wait_for with a timeout when cancelling the session consumer task and update exception catches to handle asyncio.TimeoutError
  • Consolidate exception logging to use except* Exception and add specific handling for HTTPStatusError
  • Bump package version to 0.0.93, require Python >=3.11, and update dependency versions

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
src/uipath_mcp/_cli/_runtime/_session.py Refactor task cancellation logic and switch to exception‐group logging in the server loop
src/uipath_mcp/_cli/_runtime/_runtime.py Replace broad BaseException catch with except* Exception, simplify traceback logging, handle HTTP errors
pyproject.toml Bump version to 0.0.93, require Python >=3.11, and update downstream dependency versions
.python-version Update local Python version from 3.10 to 3.11
Comments suppressed due to low confidence (1)

src/uipath_mcp/_cli/_runtime/_session.py:153

  • [nitpick] The updated message is less descriptive than the original ‘Error in server process…’; consider restoring context about where the error occurred to aid debugging.
                        f"Unexpected error for session {self._session_id}: {e}",

Comment on lines +147 to 148
except (asyncio.CancelledError, asyncio.TimeoutError):
pass
Copy link

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Swallowing TimeoutError silently may hide issues if the consumer task doesn’t shut down as expected; consider logging a warning or taking remedial action on timeout.

Suggested change
except (asyncio.CancelledError, asyncio.TimeoutError):
pass
except asyncio.CancelledError:
pass
except asyncio.TimeoutError:
logger.warning(
f"Timeout occurred while shutting down consumer task for session {self._session_id}. Task may not have terminated cleanly."
)

Copilot uses AI. Check for mistakes.
Comment on lines 382 to 388
except Exception as e:
logger.error(f"Error during registration: {e}")
if e.status_code == 400:
logger.error(f"Error details: {e.response.text}")
if isinstance(e, HTTPStatusError):
logger.error(
f"HTTP error details: {e.response.text} status code: {e.response.status_code}"
)

Copy link

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider catching HTTPStatusError explicitly before a general Exception to differentiate HTTP errors from other failures and avoid large isinstance checks in the generic handler.

Copilot uses AI. Check for mistakes.
if isinstance(e, HTTPStatusError):
logger.error(
f"HTTP error details: {e.response.text} status code: {e.response.status_code}"
)
Copy link

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Removing this info-level log may reduce visibility into client configuration during troubleshooting; consider demoting it to logger.debug instead of dropping it entirely.

Copilot uses AI. Check for mistakes.
@cristipufu cristipufu added the build:dev Create a dev build from the pr label Jul 3, 2025
@cristipufu cristipufu merged commit 6c3900b into main Jul 3, 2025
8 checks passed
@cristipufu cristipufu deleted the fix/update_3_11 branch July 3, 2025 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build:dev Create a dev build from the pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants