From 034371ba47c84f3371582e1d9f4ef2aafa43f5d1 Mon Sep 17 00:00:00 2001 From: anvil Date: Wed, 22 Apr 2026 04:46:27 +0000 Subject: [PATCH] Fix context download after space switching --- ax_cli/commands/context.py | 5 ++++- tests/test_context_commands.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ax_cli/commands/context.py b/ax_cli/commands/context.py index 4127035..30a60d7 100644 --- a/ax_cli/commands/context.py +++ b/ax_cli/commands/context.py @@ -118,7 +118,10 @@ def _fetch_context_file(client, sid: str | None, payload: dict) -> bytes: download_url = urljoin(f"{client.base_url}/", url) headers = {k: v for k, v in client._auth_headers().items() if k != "Content-Type"} with httpx.Client(headers=headers, timeout=60.0, follow_redirects=True) as http: - response = http.get(download_url, params={"space_id": sid} if sid else None) + # Upload downloads are authorized against the attachment's owning + # space. Passing the caller's current space can turn a valid download + # into a 404 after the user switches spaces. + response = http.get(download_url) response.raise_for_status() return response.content diff --git a/tests/test_context_commands.py b/tests/test_context_commands.py index bc05dd9..6a1fb58 100644 --- a/tests/test_context_commands.py +++ b/tests/test_context_commands.py @@ -69,7 +69,7 @@ def get(self, url, params=None): assert "[green]" not in result.output assert output.read_bytes() == b"png-bytes" assert calls["url"] == "https://paxai.app/api/v1/uploads/files/image.png" - assert calls["params"] == {"space_id": "space-1"} + assert calls["params"] is None assert calls["headers"] == { "Authorization": "Bearer exchanged.jwt", "X-AX-FP": "fp", @@ -143,7 +143,7 @@ def get(self, url, params=None): assert len(preview_files) == 1 assert preview_files[0].read_bytes() == b"png-bytes" assert calls["url"] == "https://paxai.app/api/v1/uploads/files/image.png" - assert calls["params"] == {"space_id": "space-1"} + assert calls["params"] is None assert calls["headers"] == {"Authorization": "Bearer exchanged.jwt"} assert '"text_like": false' in result.output