Skip to content

Commit ef655a9

Browse files
committed
Handle return value from schwab api
1 parent a7a7cf3 commit ef655a9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/schwab_mcp/tools/utils.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ async def call(func: Callable[..., Awaitable[Any]], *args: Any, **kwargs: Any) -
1414
response = await func(*args, **kwargs)
1515
response.raise_for_status()
1616

17-
if getattr(response, "status_code", None) == 204:
17+
# Handle responses with no content
18+
# 204 No Content: explicit no-content response
19+
# 201 Created: order placement endpoints return empty body with Location header
20+
status_code = getattr(response, "status_code", None)
21+
if status_code in (201, 204):
22+
return None
23+
24+
# Check if response has content before trying to parse JSON
25+
# Some endpoints (like place_order) return empty bodies even with 2xx status
26+
content = getattr(response, "content", b"")
27+
if not content or len(content) == 0:
1828
return None
1929

2030
try:

0 commit comments

Comments
 (0)