Skip to content

fix(server): serve remote-hosted image previews from their source URL - #3211

Merged
vpetersson merged 1 commit into
masterfrom
fix/remote-media-preview-and-debug-db
Jul 21, 2026
Merged

fix(server): serve remote-hosted image previews from their source URL#3211
vpetersson merged 1 commit into
masterfrom
fix/remote-media-preview-and-debug-db

Conversation

@vpetersson

Copy link
Copy Markdown
Contributor

Summary

Follow-up to the forum report "Web content doesn't display". Two independent, reproduced bugs:

1. Blank preview/download for remote-hosted images

assets_preview / assets_download chose "redirect to source URL" vs. "stream a local file" by mimetype — only webpage/streaming redirected. A remote-hosted image is stored mimetype=image with an http(s):// URI, so it fell through to the local-file lookup, found nothing on disk, and 302'd to the home page (blank preview).

Fix: dispatch on the URI scheme. Any http(s):// asset redirects to its source; only filesystem-path assets are served from disk. rtsp/rtmp streams and unknown schemes still fall back to home, unchanged.

Remote videos are downloaded to a local file by Celery, so the materially-affected case is remote images (which keep their remote URI), but the scheme-based dispatch covers both.

2. collect_debug.sh DB section threw a traceback

The host-sqlite3-missing fallback imported the pre-rewrite module path (anthias_app.models), so the debug bundle carried a Python traceback instead of any asset data — on exactly the script we ask forum users to run. The server container already ships sqlite3 and bind-mounts the DB, so the fallback now runs the same read-only queries in-container, and surfaces is_reachable (the field that tells a failed reachability probe from a working one when triaging this class of report).

Testing

  • Live on the x86 testbed (master): remote-image preview now 302 → source and renders (image/jpeg); local-image preview still served from disk (200); rtsp streams still fall to home. collect_debug.sh bundle now shows integrity check, WAL mode, asset count with unreachable tally, and full per-asset is_reachable, with PII redaction intact.
  • 4 new regression tests for remote-media preview/download; full non-integration suite green; ruff + shellcheck clean.

🤖 Generated with Claude Code

…ce URL

The asset preview and download endpoints decided whether to redirect to
the source URL or stream a local file by mimetype (webpage/streaming
only). A remote-hosted image is stored mimetype=image with an http(s)
URI, so it fell through to the local-file lookup, found no file on disk,
and 302'd to the home page — a blank preview in the management UI.

Dispatch on the URI scheme instead: any http(s) asset redirects to its
source, and only filesystem-path assets are served from disk. rtsp/rtmp
streams and unknown schemes still fall back to the home page as before.

Also fix the DB section of collect_debug.sh: its host-sqlite3-missing
fallback imported the pre-#2818 module path (anthias_app.models), so the
bundle carried a Python traceback instead of any asset data. The server
container already ships sqlite3 and bind-mounts the DB, so run the same
read-only queries there, and surface is_reachable — the field that
distinguishes a failed reachability probe from a working one when
triaging "web content doesn't display" reports.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@vpetersson
vpetersson requested a review from a team as a code owner July 21, 2026 05:17
@vpetersson
vpetersson requested a review from Copilot July 21, 2026 05:18
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes how the Django management UI serves asset preview/download responses for assets whose uri points to remote content, ensuring remote-hosted images (stored as mimetype='image' with an http(s):// URI) correctly redirect to their source instead of attempting a local-file lookup. It also repairs bin/collect_debug.sh’s database-inspection fallback so it works when host sqlite3 is missing by querying the DB via the running server container.

Changes:

  • Update assets_preview and assets_download to decide between redirect-vs-file-serve based on URI scheme (redirect for safe http(s)://, otherwise attempt local file).
  • Add regression tests covering remote image/video redirect behavior for preview and download endpoints.
  • Improve collect_debug.sh DB section: include is_reachable in inventory and use containerized sqlite3 for the fallback path.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
src/anthias_server/app/views.py Switch preview/download dispatch to scheme-based redirect for remote http(s) assets; keep local file streaming for filesystem URIs.
tests/test_template_views.py Add regression tests ensuring remote media assets redirect to their source URL for both preview and download.
bin/collect_debug.sh Fix DB inspection when host sqlite3 is missing by querying via server container; include reachability info in output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vpetersson
vpetersson merged commit 7acda8c into master Jul 21, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants