Harden export preview handling
This commit is contained in:
@@ -192,6 +192,13 @@ class ExportService:
|
||||
if not export:
|
||||
raise AppError(code="EXPORT_NOT_FOUND", message="Export not found", status_code=404)
|
||||
path = ExportService.get_export_download_path(db, export_id)
|
||||
if export.export_type == "project_report_html" or path.suffix.lower() in {".html", ".htm"}:
|
||||
raise AppError(
|
||||
code="EXPORT_CONTENT_UNSUPPORTED",
|
||||
message="Export content preview is only available for JSON and GeoJSON artifacts. Download HTML report artifacts instead.",
|
||||
details={"export_type": export.export_type},
|
||||
status_code=415,
|
||||
)
|
||||
try:
|
||||
content = json.loads(path.read_text(encoding="utf-8"))
|
||||
except json.JSONDecodeError as exc:
|
||||
|
||||
Reference in New Issue
Block a user