Skip to content

storage.download_object() silently returns redirect body instead of file bytes when storage is backed by CDN #3

Description

@SayWut

StorageClient.download_object() does not follow HTTP redirects. When the InsForge storage backend returns a 302 to the CDN (cdn.insforge.dev), httpx stops at the redirect because AsyncClient is initialized without follow_redirects=True. The method returns a StorageDownloadResult where content is the near-empty redirect body, not the actual file.

Steps to reproduce

  1. Upload a file to a private bucket using storage.upload_object()
  2. Download it using storage.download_object()
  3. Inspect result.content — it will be empty bytes or a small HTML redirect body, not the uploaded file

Expected behavior

download_object() should return the actual file bytes regardless of whether InsForge serves them directly or via a CDN redirect.

Actual behavior

Returns the 302 redirect body when the bucket is CDN-backed.

Root cause

# _base_client.py
self.http_client = httpx.AsyncClient()  # missing follow_redirects=True

download_object() calls self._client.http_client.request(...) which inherits this default. httpx.AsyncClient.request() accepts follow_redirects as a per-request parameter — the fix is straightforward.

Suggested fix

Either initialize AsyncClient with follow_redirects=True, or pass follow_redirects=True directly in the download_object request call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions