From 9b2d96786dae0e6400ff523a6209b372f9a88f4c Mon Sep 17 00:00:00 2001 From: busya Date: Mon, 1 Jun 2026 09:05:24 +0300 Subject: [PATCH] fix(validation): populate screenshot_paths column + backfill from raw_response Two bugs preventing screenshot display in report UI: 1. Plugin's ValidationRecord constructor did NOT include screenshot_paths (plural, JSON array). The column stayed NULL even though paths were stored in raw_response. Records created by the plugin now include screenshot_paths=webp_paths|jpeg_paths. 2. Backward compat for existing records: _record_to_dict now falls back to extracting screenshot_paths from raw_response JSON when the DB column is empty. Also fixes: broken import statement in validation_service.py (missing closing paren + missing imports from earlier edit). --- backend/src/plugins/llm_analysis/plugin.py | 1 + backend/src/services/validation_service.py | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/llm_analysis/plugin.py b/backend/src/plugins/llm_analysis/plugin.py index f328b3e6..00e14ad5 100644 --- a/backend/src/plugins/llm_analysis/plugin.py +++ b/backend/src/plugins/llm_analysis/plugin.py @@ -478,6 +478,7 @@ class DashboardValidationPlugin(PluginBase): summary=validation_result.summary, issues=[issue.model_dump() for issue in validation_result.issues], screenshot_path=validation_result.screenshot_path, + screenshot_paths=webp_paths or jpeg_paths, raw_response=json.dumps(result_payload, ensure_ascii=False), ) db.add(db_record) diff --git a/backend/src/services/validation_service.py b/backend/src/services/validation_service.py index 091cb90d..5b1c512e 100644 --- a/backend/src/services/validation_service.py +++ b/backend/src/services/validation_service.py @@ -22,6 +22,24 @@ from ..schemas.validation import ( ValidationTaskResponse, ValidationTaskUpdate, ) + +# #region _extract_screenshot_paths [C:2] [TYPE Function] +# @BRIEF Extract screenshot_paths from raw_response JSON when the column is empty (backward compat). +def _extract_screenshot_paths(raw_response): + if not raw_response: + return [] + import json + try: + parsed = json.loads(raw_response) + paths = parsed.get("screenshot_paths") or [] + if isinstance(paths, list): + return paths + except (json.JSONDecodeError, TypeError): + pass + return [] + + +# #endregion _extract_screenshot_paths from .llm_provider import LLMProviderService @@ -297,7 +315,9 @@ class ValidationTaskService: "issues": record.issues or [], "raw_response": record.raw_response, "screenshot_path": record.screenshot_path, - "screenshot_paths": record.screenshot_paths or [], + # screenshot_paths column may be empty for runs created before the fix; + # fall back to extracting from raw_response JSON + "screenshot_paths": record.screenshot_paths or _extract_screenshot_paths(record.raw_response), "execution_path": record.execution_path, "dataset_health": record.dataset_health, "chart_data_results": record.chart_data_results or [],