From 11daa153350461f7ed3020e6f7048266f7486365 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 29 Mar 2026 20:03:43 +0000 Subject: [PATCH] Fix domain reports and sources API 500 errors - Use begin_timestamp/end_timestamp (Unix ints) instead of begin_date/end_date (ISO strings) when building ReportEntry, fixing Pydantic int_parsing errors - Extract policy string from dict (policy["p"]) when the stored value is a dict, fixing Pydantic string_type validation error - Rename _days -> days in ReportStore.get_domain_sources() so the endpoint's `days=days` keyword call no longer raises TypeError Agent-Logs-Url: https://github.com/christianlouis/dmarq/sessions/15ac3521-e81f-42fa-81a2-f6804a423e1d Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- backend/app/api/api_v1/endpoints/domains.py | 9 ++++++--- backend/app/services/report_store.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/app/api/api_v1/endpoints/domains.py b/backend/app/api/api_v1/endpoints/domains.py index bc37ed3..f65d43d 100644 --- a/backend/app/api/api_v1/endpoints/domains.py +++ b/backend/app/api/api_v1/endpoints/domains.py @@ -371,15 +371,18 @@ async def get_domain_reports( # Generate report entries report_entries = [] for report in reports: + policy_val = report.get("policy", "none") + if isinstance(policy_val, dict): + policy_val = policy_val.get("p", "none") report_entries.append( ReportEntry( id=report.get("report_id", "unknown"), org_name=report.get("org_name", "Unknown Organization"), - begin_date=report.get("begin_date", 0), - end_date=report.get("end_date", 0), + begin_date=report.get("begin_timestamp", 0), + end_date=report.get("end_timestamp", 0), total_emails=report.get("total_count", 0), pass_rate=report.get("pass_rate", 0.0), - policy=report.get("policy", "none"), + policy=policy_val, ) ) diff --git a/backend/app/services/report_store.py b/backend/app/services/report_store.py index b057f8e..e0dee1d 100644 --- a/backend/app/services/report_store.py +++ b/backend/app/services/report_store.py @@ -177,7 +177,7 @@ class ReportStore: return sorted_reports[:limit] return sorted_reports - def get_domain_sources(self, domain: str, _days: int = 30) -> List[Dict[str, Any]]: + def get_domain_sources(self, domain: str, days: int = 30) -> List[Dict[str, Any]]: """ Get sending sources for a domain