正在 run responder 時,如果有發出 issue ,則不會觸發自動回應 #4

Closed
opened 2026-04-16 17:00:22 +08:00 by MarioYang · 1 comment
Owner

目前用gosmee

目前用gosmee
Author
Owner

[!NOTE]
Automated reply generated by code_work_spawner via gitea as @MarioYang.
Review it as bot output, not as a direct human response.

分析:正在 run responder 時新 issue 無法觸發自動回應

透過程式碼檢查,整理出幾個可能的根本原因:


可能原因 1:Responder 決定 no_reply

新 issue(沒有 mention trigger)觸發時,trigger 欄位會是 "update" 而非 "mention"。如果 responder(AI)設定為只回應 mention,就會回傳 no_reply 而不發表留言。這是最常見的情況。

確認方式:查看 log 是否出現:

decision=no_reply

可能原因 2:Webhook 在 gosmee client 啟動前送出

啟動流程為:

  1. 執行 gosmee --output json client --new-url <local> 取得 public URL(短暫連線)
  2. 向 Gitea 註冊 webhook
  3. 啟動持久的 gosmee client <public_url> <local> 程序

步驟 2 和 3 之間有短暫空窗期。若 webhook 在步驟 3 完成前送達 gosmee relay,可能遺失。


可能原因 3:_isLatestContributionFromBot 誤判 skip

若 responder 正在處理某 issue 並已發表 bot 留言,同時期間收到另一個 webhook(包含 bot 的留言),系統會正確 skip(因為 latest comment 是 bot)。

但如果時序問題導致新 issue 的 webhook 附帶了 bot 的留言資訊,也可能誤 skip。


可能原因 4:unawaited(_flushQueuedIssues()) 例外被吞掉

_scheduleFlush() 使用 unawaited 呼叫 _flushQueuedIssues()。若 _flushQueuedIssues 內部丟出未捕捉的例外(例如 DB 操作失敗),錯誤會被靜默忽略,後續 issue 無法處理。


建議的除錯步驟

  1. 確認 log 中是否有 gitea/gosmee webhook accepted 訊息(確認 webhook 有送達)
  2. 確認是否出現 skip issue ... reason=...
  3. 確認 responder 的 decision
  4. 可暫時調高 log level 以看到 logDebug 訊息

可能的程式碼改善

_scheduleFlush 中加入例外處理,避免錯誤被靜默吞掉:

void _scheduleFlush() {
  _flushTimer ??= Timer(_webhookCoalescingWindow, () {
    _flushTimer = null;
    _flushQueuedIssues().catchError((Object error, StackTrace stack) {
      _logError('gitea/gosmee flush_error error=$error');
    });
  });
}

您是否可以提供觸發時的 log 輸出,以便進一步確認是哪個環節出問題?

Automation note: generated by code_work_spawner via gitea as @MarioYang.

> [!NOTE] > Automated reply generated by `code_work_spawner` via `gitea` as `@MarioYang`. > Review it as bot output, not as a direct human response. ## 分析:正在 run responder 時新 issue 無法觸發自動回應 透過程式碼檢查,整理出幾個可能的根本原因: --- ### 可能原因 1:Responder 決定 `no_reply` 新 issue(沒有 mention trigger)觸發時,`trigger` 欄位會是 `"update"` 而非 `"mention"`。如果 responder(AI)設定為只回應 mention,就會回傳 `no_reply` 而不發表留言。這是最常見的情況。 **確認方式**:查看 log 是否出現: ``` decision=no_reply ``` --- ### 可能原因 2:Webhook 在 gosmee client 啟動前送出 啟動流程為: 1. 執行 `gosmee --output json client --new-url <local>` 取得 public URL(短暫連線) 2. 向 Gitea 註冊 webhook 3. 啟動持久的 `gosmee client <public_url> <local>` 程序 步驟 2 和 3 之間有短暫空窗期。若 webhook 在步驟 3 完成前送達 gosmee relay,可能遺失。 --- ### 可能原因 3:`_isLatestContributionFromBot` 誤判 skip 若 responder 正在處理某 issue 並已發表 bot 留言,同時期間收到另一個 webhook(包含 bot 的留言),系統會正確 skip(因為 latest comment 是 bot)。 但如果時序問題導致新 issue 的 webhook 附帶了 bot 的留言資訊,也可能誤 skip。 --- ### 可能原因 4:`unawaited(_flushQueuedIssues())` 例外被吞掉 `_scheduleFlush()` 使用 `unawaited` 呼叫 `_flushQueuedIssues()`。若 `_flushQueuedIssues` 內部丟出未捕捉的例外(例如 DB 操作失敗),錯誤會被靜默忽略,後續 issue 無法處理。 --- ### 建議的除錯步驟 1. 確認 log 中是否有 `gitea/gosmee webhook accepted` 訊息(確認 webhook 有送達) 2. 確認是否出現 `skip issue ... reason=...` 3. 確認 responder 的 `decision` 值 4. 可暫時調高 log level 以看到 `logDebug` 訊息 --- ### 可能的程式碼改善 在 `_scheduleFlush` 中加入例外處理,避免錯誤被靜默吞掉: ```dart void _scheduleFlush() { _flushTimer ??= Timer(_webhookCoalescingWindow, () { _flushTimer = null; _flushQueuedIssues().catchError((Object error, StackTrace stack) { _logError('gitea/gosmee flush_error error=$error'); }); }); } ``` 您是否可以提供觸發時的 log 輸出,以便進一步確認是哪個環節出問題? _Automation note: generated by `code_work_spawner` via `gitea` as `@MarioYang`._ <!-- code-work-spawner:34904042d9b0658c41166a7f7441535fc96ee86cd7afb73199bbee5a32e116a4 -->
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: MarioYang/code_work_spawner#4
No description provided.