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:
@@ -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)
|
||||
|
||||
@@ -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 [],
|
||||
|
||||
Reference in New Issue
Block a user