fix(server): serve remote-hosted image previews from their source URL - #3211
Conversation
…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]>
|
There was a problem hiding this comment.
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_previewandassets_downloadto decide between redirect-vs-file-serve based on URI scheme (redirect for safehttp(s)://, otherwise attempt local file). - Add regression tests covering remote image/video redirect behavior for preview and download endpoints.
- Improve
collect_debug.shDB section: includeis_reachablein inventory and use containerizedsqlite3for 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.



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_downloadchose "redirect to source URL" vs. "stream a local file" by mimetype — onlywebpage/streamingredirected. A remote-hosted image is storedmimetype=imagewith anhttp(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/rtmpstreams 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.shDB section threw a tracebackThe 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 shipssqlite3and bind-mounts the DB, so the fallback now runs the same read-only queries in-container, and surfacesis_reachable(the field that tells a failed reachability probe from a working one when triaging this class of report).Testing
302 → sourceand renders (image/jpeg); local-image preview still served from disk (200);rtspstreams still fall to home.collect_debug.shbundle now shows integrity check, WAL mode, asset count with unreachable tally, and full per-assetis_reachable, with PII redaction intact.ruff+shellcheckclean.🤖 Generated with Claude Code