-
Notifications
You must be signed in to change notification settings - Fork 354
fix(fetch): fix fetchurl tool incorrect output when fetching via service fails #451
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -29,15 +29,17 @@ def __init__(self, config: Config): | |||||
|
|
||||||
| @override | ||||||
| async def __call__(self, params: Params) -> ToolReturnValue: | ||||||
| builder = ToolResultBuilder(max_line_length=None) | ||||||
|
|
||||||
| if self._service_config: | ||||||
| result = await self._fetch_with_service(params, builder) | ||||||
| if isinstance(result, ToolOk): | ||||||
| return result | ||||||
| logger.warning("Failed to fetch URL via service: {error}", error=result.message) | ||||||
| ret = await self._fetch_with_service(params) | ||||||
| if isinstance(ret, ToolOk): | ||||||
| return ret | ||||||
| logger.warning("Failed to fetch URL via service: {error}", error=ret.message) | ||||||
| # fallback to local fetch if service fetch fails | ||||||
| return await self.fetch_with_http_get(params) | ||||||
|
|
||||||
| @staticmethod | ||||||
| async def fetch_with_http_get(params: Params) -> ToolReturnValue: | ||||||
| builder = ToolResultBuilder() | ||||||
|
||||||
| builder = ToolResultBuilder() | |
| builder = ToolResultBuilder(max_line_length=None) |
stdrc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new error handling for network errors when calling the fetch service lacks test coverage. While there's a test for successful service calls (test_fetch_url_with_service in tests/test_fetch_url.py), there's no test for when:
- The service is unreachable (network error)
- The service returns a non-200 status code with the new error path
Consider adding tests to verify:
- The fallback to HTTP GET works when the service encounters a network error
- The error message format is correct for network errors
- The logging behavior (warning message at line 36)
Uh oh!
There was an error while loading. Please reload this page.