From 56a530c8bf71fe23428f468452ba184860e28db5 Mon Sep 17 00:00:00 2001 From: "alan.cl" <1165243776@qq.com> Date: Mon, 2 Mar 2026 21:29:09 +0800 Subject: [PATCH] fix: fix duplicate image in html report --- .../openapi/api_v1/agentic_data_api.py | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/agentic_data_api.py b/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/agentic_data_api.py index 9ed3b45f3..8dce88f85 100644 --- a/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/agentic_data_api.py +++ b/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/agentic_data_api.py @@ -2015,8 +2015,24 @@ print(json.dumps(summary, ensure_ascii=False)) try: gen_images = react_state.get("generated_images", []) if gen_images: - # Find which images are NOT already referenced in the HTML - missing = [url for url in gen_images if url not in fixed_html] + # Extract all image filenames already referenced in the HTML + # (e.g. "time_series_trend.png" from any src="...time_series_trend.png") + html_img_stems = set( + re.sub(r"^[0-9a-f]+_", "", os.path.basename(src)) + for src in re.findall( + r']+src=["\']([^"\']+)["\']', fixed_html, re.IGNORECASE + ) + ) + # An image is "missing" only when neither its exact URL nor its + # stem (filename with UUID prefix stripped) is already covered. + def _img_stem(url): + return re.sub(r"^[0-9a-f]+_", "", os.path.basename(url)) + + missing = [ + url + for url in gen_images + if url not in fixed_html and _img_stem(url) not in html_img_stems + ] if missing: imgs_html = "".join( f'
'