debug: add logging to reaction handler for approval flow diagnosis
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
13
bot.py
13
bot.py
@@ -1475,6 +1475,8 @@ class Bot:
|
|||||||
event_id = event.reacts_to
|
event_id = event.reacts_to
|
||||||
reaction_key = event.key
|
reaction_key = event.key
|
||||||
|
|
||||||
|
logger.info("Reaction received: key=%s reacts_to=%s sender=%s", reaction_key, event_id, event.sender)
|
||||||
|
|
||||||
# Check if this reaction is for a pipeline approval
|
# Check if this reaction is for a pipeline approval
|
||||||
if not self.cron_scheduler:
|
if not self.cron_scheduler:
|
||||||
return
|
return
|
||||||
@@ -1482,8 +1484,14 @@ class Bot:
|
|||||||
from pipelines.approval import reaction_to_response
|
from pipelines.approval import reaction_to_response
|
||||||
response = reaction_to_response(reaction_key)
|
response = reaction_to_response(reaction_key)
|
||||||
if not response:
|
if not response:
|
||||||
|
logger.debug("Reaction key %s not an approval response", reaction_key)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
logger.info("Approval reaction: %s -> %s (tracked events: %s, active futures: %s)",
|
||||||
|
event_id, response,
|
||||||
|
list(self._pipeline_approval_events.keys()),
|
||||||
|
list(self.cron_scheduler.pipeline_engine._approval_futures.keys()))
|
||||||
|
|
||||||
# Look up execution by approval event ID
|
# Look up execution by approval event ID
|
||||||
execution_id = self._pipeline_approval_events.get(event_id)
|
execution_id = self._pipeline_approval_events.get(event_id)
|
||||||
if execution_id:
|
if execution_id:
|
||||||
@@ -1492,10 +1500,13 @@ class Bot:
|
|||||||
self._pipeline_approval_events.pop(event_id, None)
|
self._pipeline_approval_events.pop(event_id, None)
|
||||||
logger.info("Pipeline approval resolved: %s -> %s", execution_id, response)
|
logger.info("Pipeline approval resolved: %s -> %s", execution_id, response)
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
logger.warning("Failed to resolve approval %s (future not found or already done)", execution_id)
|
||||||
|
|
||||||
# If not in local cache, check pending approvals from portal
|
# If not in local cache, check pending approvals from portal
|
||||||
try:
|
try:
|
||||||
pending = await self.cron_scheduler._pipeline_state.fetch_pending_approvals()
|
pending = await self.cron_scheduler._pipeline_state.fetch_pending_approvals()
|
||||||
|
logger.info("Checking %d pending approvals from portal for event %s", len(pending), event_id)
|
||||||
for execution in pending:
|
for execution in pending:
|
||||||
if execution.get("approvalMsgId") == event_id:
|
if execution.get("approvalMsgId") == event_id:
|
||||||
eid = execution["id"]
|
eid = execution["id"]
|
||||||
@@ -1504,6 +1515,8 @@ class Bot:
|
|||||||
if resolved:
|
if resolved:
|
||||||
self._pipeline_approval_events.pop(event_id, None)
|
self._pipeline_approval_events.pop(event_id, None)
|
||||||
logger.info("Pipeline approval resolved (from portal): %s -> %s", eid, response)
|
logger.info("Pipeline approval resolved (from portal): %s -> %s", eid, response)
|
||||||
|
else:
|
||||||
|
logger.warning("Portal found execution %s but future not active", eid)
|
||||||
break
|
break
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.debug("Failed to check pending approvals for reaction", exc_info=True)
|
logger.debug("Failed to check pending approvals for reaction", exc_info=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user