fix(zopk): Capture current_user.id before SSE generator
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Flask-Login's current_user proxy loses context inside generator functions, causing 'NoneType' has no attribute 'id' error. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
683df8f43d
commit
fae7bfa0b2
@ -591,6 +591,7 @@ def api_zopk_search_news_stream():
|
||||
from zopk_news_service import ZOPKNewsService
|
||||
|
||||
query = request.args.get('query', 'Zielony Okręg Przemysłowy Kaszubia')
|
||||
user_id = current_user.id # Capture before generator (proxy loses context inside)
|
||||
|
||||
def generate():
|
||||
db = SessionLocal()
|
||||
@ -602,7 +603,7 @@ def api_zopk_search_news_stream():
|
||||
search_query=query,
|
||||
search_api='multi_source_sse',
|
||||
triggered_by='admin',
|
||||
triggered_by_user=current_user.id,
|
||||
triggered_by_user=user_id,
|
||||
status='running',
|
||||
started_at=datetime.now()
|
||||
)
|
||||
@ -620,7 +621,7 @@ def api_zopk_search_news_stream():
|
||||
try:
|
||||
service = ZOPKNewsService(db)
|
||||
result_holder[0] = service.search_all_sources(
|
||||
query, user_id=current_user.id, progress_callback=on_progress
|
||||
query, user_id=user_id, progress_callback=on_progress
|
||||
)
|
||||
except Exception as e:
|
||||
error_holder[0] = e
|
||||
|
||||
Loading…
Reference in New Issue
Block a user