Skip to content

Commit 2ccacd7

Browse files
jfrench9claude
andauthored
feat: enhance API client robustness with improved error handling (#55)
## Summary This PR significantly enhances the robustness and reliability of the RoboSystems API client by implementing comprehensive error handling improvements and safer URL parameter handling across all API endpoints. ## Key Accomplishments - **Enhanced Error Handling**: Improved HTTP response error handling in the QueryClient to provide better error messages and more graceful failure modes - **Safer URL Parameter Handling**: Updated URL formatting across all API calls to use proper quoting mechanisms, preventing issues with special characters and improving security - **Comprehensive Coverage**: Applied improvements consistently across 80 API endpoint files covering all major service areas: - Agent operations (auto-select, batch processing, execution, metadata) - Backup and restore functionality - Billing and subscription management - Connection management and OAuth flows - Credits and storage monitoring - File operations - Graph health, info, and limits - Materialization processes - MCP tool integration - Operations management - Organization and member management - Query execution - Schema operations - Subgraph management - Subscription handling - Table operations - Usage analytics - User management - View operations ## Breaking Changes None. These changes are backward-compatible and only enhance the existing functionality without modifying public APIs. ## Testing Notes - All existing API functionality should continue to work as expected - Error responses should now provide more informative messages - URLs with special characters in parameters should be handled more reliably - Test cases involving malformed parameters or edge cases should show improved behavior ## Infrastructure Considerations - The QueryClient improvements may change the format of error messages, which could affect logging and monitoring - URL encoding changes ensure better compliance with HTTP standards and may resolve issues with certain parameter values - These changes improve the overall stability and security posture of API communications --- 🤖 Generated with [Claude Code](https://claude.ai/code) **Branch Info:** - Source: `feature/more-robust-gen` - Target: `main` - Type: feature Co-Authored-By: Claude <noreply@anthropic.com>
2 parents 893088f + 723fe6a commit 2ccacd7

80 files changed

Lines changed: 350 additions & 79 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

robosystems_client/api/agent/auto_select_agent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from http import HTTPStatus
22
from typing import Any, cast
3+
from urllib.parse import quote
34

45
import httpx
56

@@ -36,7 +37,9 @@ def _get_kwargs(
3637

3738
_kwargs: dict[str, Any] = {
3839
"method": "post",
39-
"url": f"/v1/graphs/{graph_id}/agent",
40+
"url": "/v1/graphs/{graph_id}/agent".format(
41+
graph_id=quote(str(graph_id), safe=""),
42+
),
4043
"params": params,
4144
}
4245

robosystems_client/api/agent/batch_process_queries.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from http import HTTPStatus
22
from typing import Any, cast
3+
from urllib.parse import quote
34

45
import httpx
56

@@ -20,7 +21,9 @@ def _get_kwargs(
2021

2122
_kwargs: dict[str, Any] = {
2223
"method": "post",
23-
"url": f"/v1/graphs/{graph_id}/agent/batch",
24+
"url": "/v1/graphs/{graph_id}/agent/batch".format(
25+
graph_id=quote(str(graph_id), safe=""),
26+
),
2427
}
2528

2629
_kwargs["json"] = body.to_dict()

robosystems_client/api/agent/execute_specific_agent.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from http import HTTPStatus
22
from typing import Any, cast
3+
from urllib.parse import quote
34

45
import httpx
56

@@ -37,7 +38,10 @@ def _get_kwargs(
3738

3839
_kwargs: dict[str, Any] = {
3940
"method": "post",
40-
"url": f"/v1/graphs/{graph_id}/agent/{agent_type}",
41+
"url": "/v1/graphs/{graph_id}/agent/{agent_type}".format(
42+
graph_id=quote(str(graph_id), safe=""),
43+
agent_type=quote(str(agent_type), safe=""),
44+
),
4145
"params": params,
4246
}
4347

robosystems_client/api/agent/get_agent_metadata.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from http import HTTPStatus
22
from typing import Any, cast
3+
from urllib.parse import quote
34

45
import httpx
56

@@ -16,7 +17,10 @@ def _get_kwargs(
1617
) -> dict[str, Any]:
1718
_kwargs: dict[str, Any] = {
1819
"method": "get",
19-
"url": f"/v1/graphs/{graph_id}/agent/{agent_type}",
20+
"url": "/v1/graphs/{graph_id}/agent/{agent_type}".format(
21+
graph_id=quote(str(graph_id), safe=""),
22+
agent_type=quote(str(agent_type), safe=""),
23+
),
2024
}
2125

2226
return _kwargs

robosystems_client/api/agent/list_agents.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from http import HTTPStatus
22
from typing import Any, cast
3+
from urllib.parse import quote
34

45
import httpx
56

@@ -28,7 +29,9 @@ def _get_kwargs(
2829

2930
_kwargs: dict[str, Any] = {
3031
"method": "get",
31-
"url": f"/v1/graphs/{graph_id}/agent",
32+
"url": "/v1/graphs/{graph_id}/agent".format(
33+
graph_id=quote(str(graph_id), safe=""),
34+
),
3235
"params": params,
3336
}
3437

robosystems_client/api/agent/recommend_agent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from http import HTTPStatus
22
from typing import Any, cast
3+
from urllib.parse import quote
34

45
import httpx
56

@@ -20,7 +21,9 @@ def _get_kwargs(
2021

2122
_kwargs: dict[str, Any] = {
2223
"method": "post",
23-
"url": f"/v1/graphs/{graph_id}/agent/recommend",
24+
"url": "/v1/graphs/{graph_id}/agent/recommend".format(
25+
graph_id=quote(str(graph_id), safe=""),
26+
),
2427
}
2528

2629
_kwargs["json"] = body.to_dict()

robosystems_client/api/backup/create_backup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from http import HTTPStatus
22
from typing import Any
3+
from urllib.parse import quote
34

45
import httpx
56

@@ -20,7 +21,9 @@ def _get_kwargs(
2021

2122
_kwargs: dict[str, Any] = {
2223
"method": "post",
23-
"url": f"/v1/graphs/{graph_id}/backups",
24+
"url": "/v1/graphs/{graph_id}/backups".format(
25+
graph_id=quote(str(graph_id), safe=""),
26+
),
2427
}
2528

2629
_kwargs["json"] = body.to_dict()

robosystems_client/api/backup/get_backup_download_url.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from http import HTTPStatus
22
from typing import Any, cast
3+
from urllib.parse import quote
34

45
import httpx
56

@@ -24,7 +25,10 @@ def _get_kwargs(
2425

2526
_kwargs: dict[str, Any] = {
2627
"method": "get",
27-
"url": f"/v1/graphs/{graph_id}/backups/{backup_id}/download",
28+
"url": "/v1/graphs/{graph_id}/backups/{backup_id}/download".format(
29+
graph_id=quote(str(graph_id), safe=""),
30+
backup_id=quote(str(backup_id), safe=""),
31+
),
2832
"params": params,
2933
}
3034

robosystems_client/api/backup/get_backup_stats.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from http import HTTPStatus
22
from typing import Any
3+
from urllib.parse import quote
34

45
import httpx
56

@@ -15,7 +16,9 @@ def _get_kwargs(
1516
) -> dict[str, Any]:
1617
_kwargs: dict[str, Any] = {
1718
"method": "get",
18-
"url": f"/v1/graphs/{graph_id}/backups/stats",
19+
"url": "/v1/graphs/{graph_id}/backups/stats".format(
20+
graph_id=quote(str(graph_id), safe=""),
21+
),
1922
}
2023

2124
return _kwargs

robosystems_client/api/backup/list_backups.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from http import HTTPStatus
22
from typing import Any
3+
from urllib.parse import quote
34

45
import httpx
56

@@ -26,7 +27,9 @@ def _get_kwargs(
2627

2728
_kwargs: dict[str, Any] = {
2829
"method": "get",
29-
"url": f"/v1/graphs/{graph_id}/backups",
30+
"url": "/v1/graphs/{graph_id}/backups".format(
31+
graph_id=quote(str(graph_id), safe=""),
32+
),
3033
"params": params,
3134
}
3235

0 commit comments

Comments
 (0)