From 1d409d7929b4c777fdf4ffe23c90cacefc0317a3 Mon Sep 17 00:00:00 2001 From: dextmorgn <64375473+dextmorgn@users.noreply.github.com> Date: Sat, 30 May 2026 19:02:14 +0200 Subject: [PATCH] fix(scan): persist results to existing details column, errors to error column MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Scan model exposes details (JSON) and error (Text) columns, but the enricher/flow tasks assigned to scan.results — a non-mapped attribute. SQLAlchemy accepted the assignment silently, so commit() never persisted it and the data was lost. Success paths now write scan.details; failure paths write scan.error. ScanCreate.results renamed to details to match. Scan repository tests pass. --- flowsint-api/app/api/schemas/scan.py | 2 +- flowsint-core/src/flowsint_core/tasks/enricher.py | 12 ++++++------ flowsint-core/src/flowsint_core/tasks/flow.py | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/flowsint-api/app/api/schemas/scan.py b/flowsint-api/app/api/schemas/scan.py index b39d4aa1..f1e70f9b 100644 --- a/flowsint-api/app/api/schemas/scan.py +++ b/flowsint-api/app/api/schemas/scan.py @@ -8,7 +8,7 @@ class ScanCreate(BaseModel): values: Optional[List[str]] = None sketch_id: Optional[UUID4] = None status: Optional[str] = None - results: Optional[Any] = None + details: Optional[Any] = None class ScanRead(ORMBase): diff --git a/flowsint-core/src/flowsint_core/tasks/enricher.py b/flowsint-core/src/flowsint_core/tasks/enricher.py index f08ede65..1238f057 100644 --- a/flowsint-core/src/flowsint_core/tasks/enricher.py +++ b/flowsint-core/src/flowsint_core/tasks/enricher.py @@ -69,10 +69,10 @@ def run_enricher( results = asyncio.run(enricher.execute(values=serialized_objects)) scan.status = EventLevel.COMPLETED - scan.results = to_json_serializable(results) + scan.details = to_json_serializable(results) session.commit() - return {"result": scan.results} + return {"result": scan.details} except Exception as ex: session.rollback() @@ -82,7 +82,7 @@ def run_enricher( scan = session.query(Scan).filter(Scan.id == uuid.UUID(self.request.id)).first() if scan: scan.status = EventLevel.FAILED - scan.results = {"error": error_logs} + scan.error = error_logs session.commit() self.update_state(state=states.FAILURE) @@ -145,10 +145,10 @@ def run_template_enricher( results = asyncio.run(enricher.execute(values=serialized_objects)) scan.status = EventLevel.COMPLETED - scan.results = to_json_serializable(results) + scan.details = to_json_serializable(results) session.commit() - return {"result": scan.results} + return {"result": scan.details} except Exception as ex: session.rollback() @@ -162,7 +162,7 @@ def run_template_enricher( ) if scan: scan.status = EventLevel.FAILED - scan.results = {"error": error_logs} + scan.error = error_logs session.commit() self.update_state(state=states.FAILURE) diff --git a/flowsint-core/src/flowsint_core/tasks/flow.py b/flowsint-core/src/flowsint_core/tasks/flow.py index ebce0256..25cc2c46 100644 --- a/flowsint-core/src/flowsint_core/tasks/flow.py +++ b/flowsint-core/src/flowsint_core/tasks/flow.py @@ -65,10 +65,10 @@ def run_flow( results = enricher.scan(values=serialized_objects) scan.status = EventLevel.COMPLETED - scan.results = to_json_serializable(results) + scan.details = to_json_serializable(results) session.commit() - return {"result": scan.results} + return {"result": scan.details} except Exception as ex: session.rollback() @@ -78,7 +78,7 @@ def run_flow( scan = session.query(Scan).filter(Scan.id == uuid.UUID(self.request.id)).first() if scan: scan.status = EventLevel.FAILED - scan.results = {"error": error_logs} + scan.error = error_logs session.commit() self.update_state(state=states.FAILURE)