From 99b041a0dd37ef6349cb3a080ce83d1d122d9818 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Mon, 23 Feb 2026 20:57:11 +0000 Subject: [PATCH] fix: flush article before creating sentiment FK references ArticleSentiment referenced db_article.id before the Article was flushed, causing a NotNullViolationError on the article_id column. Adding an explicit flush after session.add(db_article) ensures the UUID is populated before creating the foreign key reference. --- services/sentiment_analyzer/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/services/sentiment_analyzer/main.py b/services/sentiment_analyzer/main.py index c645223..4e9c4f9 100644 --- a/services/sentiment_analyzer/main.py +++ b/services/sentiment_analyzer/main.py @@ -125,6 +125,7 @@ async def process_article( content_hash=article.content_hash, ) session.add(db_article) + await session.flush() for ticker in tickers: sentiment = ArticleSentiment(