Skip to content

Commit bd02919

Browse files
committed
fixed oauth exceptions
1 parent ec8b922 commit bd02919

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "chuk-tool-processor"
7-
version = "0.9.5"
7+
version = "0.9.6"
88
description = "Async-native framework for registering, discovering, and executing tools referenced in LLM responses"
99
readme = "README.md"
1010
requires-python = ">=3.11"

src/chuk_tool_processor/mcp/transport/http_streamable_transport.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,13 @@ async def initialize(self) -> bool:
239239
await self._cleanup()
240240
if self.enable_metrics and self._metrics:
241241
self._metrics.connection_errors += 1
242-
return False
242+
raise # Re-raise for OAuth error detection in mcp-cli
243243
except Exception as e:
244244
logger.error("Error initializing HTTP Streamable transport: %s", e, exc_info=True)
245245
await self._cleanup()
246246
if self.enable_metrics and self._metrics:
247247
self._metrics.connection_errors += 1
248-
return False
248+
raise # Re-raise for OAuth error detection in mcp-cli
249249

250250
async def _attempt_recovery(self) -> bool:
251251
"""Attempt to recover from connection issues (NEW - like SSE resilience)."""

tests/mcp/transport/test_http_streamable.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,14 @@ async def test_initialize_timeout(self, transport):
132132
# Simulate timeout during context entry
133133
mock_http_transport.__aenter__.side_effect = TimeoutError()
134134

135-
result = await transport.initialize()
135+
# Now expecting TimeoutError to be raised instead of returning False
136+
with pytest.raises(TimeoutError):
137+
await transport.initialize()
136138

137-
assert result is False
138139
assert transport._initialized is False
140+
# Check metrics were updated
141+
metrics = transport.get_metrics()
142+
assert metrics["connection_errors"] == 1
139143

140144
@pytest.mark.asyncio
141145
async def test_send_ping_success(self, transport):
@@ -555,8 +559,14 @@ async def test_initialize_with_exception(self, transport):
555559
"chuk_tool_processor.mcp.transport.http_streamable_transport.ChukHTTPTransport",
556560
side_effect=Exception("Connection error"),
557561
):
558-
result = await transport.initialize()
559-
assert result is False
562+
# Now expecting Exception to be raised instead of returning False
563+
with pytest.raises(Exception, match="Connection error"):
564+
await transport.initialize()
565+
566+
assert transport._initialized is False
567+
# Check metrics were updated
568+
metrics = transport.get_metrics()
569+
assert metrics["connection_errors"] == 1
560570

561571
@pytest.mark.asyncio
562572
async def test_send_ping_increments_failures(self, transport):
@@ -791,8 +801,11 @@ async def test_initialize_connection_error_increments_metric(self, transport):
791801
"chuk_tool_processor.mcp.transport.http_streamable_transport.ChukHTTPTransport",
792802
side_effect=Exception("Connection error"),
793803
):
794-
result = await transport.initialize()
795-
assert result is False
804+
# Now expecting Exception to be raised instead of returning False
805+
with pytest.raises(Exception, match="Connection error"):
806+
await transport.initialize()
807+
808+
assert transport._initialized is False
796809
assert transport._metrics.connection_errors == 1
797810

798811
@pytest.mark.asyncio

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)