From 41fd7e36d152ef5725fb8be36929263949bef166 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Tue, 28 Apr 2026 08:53:32 +0200 Subject: [PATCH] fix: use string-converted findings in summary builder Co-Authored-By: Claude Opus 4.6 (1M context) --- .../compliance/api/agent_analyze_routes.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/backend-compliance/compliance/api/agent_analyze_routes.py b/backend-compliance/compliance/api/agent_analyze_routes.py index ec9e116..3198548 100644 --- a/backend-compliance/compliance/api/agent_analyze_routes.py +++ b/backend-compliance/compliance/api/agent_analyze_routes.py @@ -77,7 +77,10 @@ async def analyze_url(req: AnalyzeRequest): # Step 5: Build summary findings = assessment.get("triggered_rules", []) controls = assessment.get("required_controls", []) - summary = _build_summary(req.url, classification, assessment, role) + # Convert for summary (use string lists, not raw dicts) + findings_str = _to_string_list(findings) + controls_str = _to_string_list(controls) + summary = _build_summary(req.url, classification, assessment, role, findings_str, controls_str) # Step 6: Send notification email_result = send_email( @@ -229,17 +232,18 @@ def _risk_to_escalation(risk_level: str) -> str: return mapping.get(risk_level.upper() if risk_level else "", "E0") -def _build_summary(url: str, classification: str, assessment: dict, role: str) -> str: +def _build_summary( + url: str, classification: str, assessment: dict, role: str, + findings_str: list[str], controls_str: list[str], +) -> str: """Build a German manager summary.""" risk = assessment.get("risk_level", "unbekannt") score = assessment.get("risk_score", 0) - findings = assessment.get("triggered_rules", []) - controls = assessment.get("required_controls", []) recommendation = assessment.get("recommendation", "") dsfa = assessment.get("dsfa_recommended", False) - findings_text = "\n".join(f"- {f}" for f in findings[:5]) if findings else "Keine" - controls_text = "\n".join(f"- {c}" for c in controls[:5]) if controls else "Keine" + findings_text = "\n".join(f"- {f}" for f in findings_str[:5]) if findings_str else "Keine" + controls_text = "\n".join(f"- {c}" for c in controls_str[:5]) if controls_str else "Keine" parts = [ f"Dokumenttyp: {classification}",