fix(pipeline): premature state update + reject 재생성 알림
버그1: /feedback approve가 bg task 시작 전에 state를 next_pending으로 set → polling이 빈 video_url로 알림 발송. bg task의 run_step이 state를 set하도록 일임 — 이중 update 제거. 버그2: reject 후 같은 *_pending 상태로 재생성됐을 때 dedupe에 막혀 알림이 안 감. dedupe 키에 feedback_count_per_step[step]을 포함 — 재생성마다 count가 증가하므로 키가 달라져 재알림 동작.
This commit is contained in:
@@ -1009,11 +1009,19 @@ async def feedback(pid: int, req: FeedbackRequest, bg: BackgroundTasks):
|
||||
|
||||
if req.intent == "approve":
|
||||
from .pipeline.state_machine import next_state_on_approve
|
||||
next_st = next_state_on_approve(state)
|
||||
_db_module.update_pipeline_state(pid, next_st)
|
||||
# Validate transition is legal
|
||||
try:
|
||||
next_st = next_state_on_approve(state)
|
||||
except ValueError as e:
|
||||
raise HTTPException(400, str(e))
|
||||
next_step = _state_to_step(next_st)
|
||||
if next_step:
|
||||
# bg task will set state to the new *_pending when step completes
|
||||
bg.add_task(orchestrator.run_step, pid, next_step)
|
||||
else:
|
||||
# No step to run — fall through to direct state update
|
||||
# (defensive — current code paths don't hit this)
|
||||
_db_module.update_pipeline_state(pid, next_st)
|
||||
return {"ok": True}
|
||||
|
||||
elif req.intent == "reject":
|
||||
|
||||
Reference in New Issue
Block a user