Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ax_cli/commands/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions tests/test_context_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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

Expand Down