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).
This commit is contained in:
2026-06-01 09:05:24 +03:00
parent 79d8d5f7bb
commit 9b2d96786d
2 changed files with 22 additions and 1 deletions

View File

@@ -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)

View File

@@ -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 [],