Skip to content

Commit 6e649ba

Browse files
RafaelPogithub-actions[bot]
authored andcommitted
fix(mcp): use relative path for httpx download request (#5003)
## Summary - The download route's `http.get(f"/tasks/{task_id}/result")` has a leading `/` which causes httpx to replace the base URL's path (RFC 3986), sending requests to `https://host/tasks/…` instead of `https://host/api/v0/tasks/…` - Fix: use relative path `tasks/{id}/result` and ensure `base_url` ends with trailing `/` Follow-up to #5001 — caught by AI code review before it hit production. ## Test plan - [x] 60 tests pass (routes, integration, result_store) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Sourced from commit bdcdb323a05f2b27f552d53e136ca6c36e87fd7f
1 parent 6b9dbda commit 6e649ba

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

  • futuresearch-mcp/src/futuresearch_mcp

futuresearch-mcp/src/futuresearch_mcp/routes.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,17 @@ async def api_download(request: Request) -> Response: # noqa: PLR0911
272272
)
273273

274274
try:
275+
# Trailing slash on base_url is required for httpx to append
276+
# relative paths correctly (RFC 3986). A leading slash on the
277+
# request path would *replace* the base path, sending the
278+
# request to https://host/tasks/… instead of …/api/v0/tasks/….
279+
base = settings.futuresearch_api_url.rstrip("/") + "/"
275280
async with httpx.AsyncClient(
276-
base_url=settings.futuresearch_api_url,
281+
base_url=base,
277282
headers={"Authorization": f"Bearer {api_key}"},
278283
) as http:
279284
resp = await http.get(
280-
f"/tasks/{task_id}/result",
285+
f"tasks/{task_id}/result",
281286
params={"offset": 0, "limit": 100000},
282287
)
283288
resp.raise_for_status()

0 commit comments

Comments
 (0)