Skip to content

fix: markProcessed on chatops auth-fail / exception paths (Bug #6)#51

Open
avrabe wants to merge 1 commit into
mainfrom
fix/chatops-mark-processed
Open

fix: markProcessed on chatops auth-fail / exception paths (Bug #6)#51
avrabe wants to merge 1 commit into
mainfrom
fix/chatops-mark-processed

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented May 2, 2026

Summary

  • issues.opened now wraps in try/finally so the delivery is marked even when handleChatopsIssue or downstream octokit calls throw.
  • issue_comment.created auth-failure early returns (10 sites) now mark before returning. Free-text comments unchanged (still unmarked, preserving the dedup-skip path for common case).
  • Closes Bug feat: add governance dashboard and CLI tool #6 from `docs/agent-fleet/bugs.md`.

Why

Probot retries webhooks ~5 times on 5xx/timeout. The previous code skipped markProcessed on auth-failure replies and exceptions during command bodies, producing duplicate "❌ unauthorised" comments and duplicate analysis-report issues on retry.

Behaviour change matrix

Path Before After
Successful command marked marked (unchanged)
Free-text comment, no slash unmarked unmarked (unchanged)
Auth-failure rejection (org/allowed-user) unmarked marked
/review-pr on plain issue unmarked marked
/allow-merge-commit non-admin unmarked marked
Octokit throws mid-issues.opened unmarked, retries marked, swallowed

Test plan

  • 4 new tests covering auth-fail-marks + exception-marks paths
  • `npm test` → 837 pass (was 834)
  • `npm run lint` → clean

Risk

Low. Behaviour change is narrow — paths that already had visible side effects now also persist their dedup state. No paths that previously marked stop marking.

🤖 Generated with Claude Code

Why: QA bug-hunter flagged that auth-failure early returns and
exceptions in `handleChatopsIssue` skipped `markProcessed`. Probot
retries the webhook ~5 times on 5xx/timeout, so the user got duplicate
"❌ unauthorised" comments and duplicate analysis-report issues.

What:
  - issues.opened: wrap the body in try/finally so the delivery is
    marked even when handleChatopsIssue or any octokit call throws.
    Logger captures the error so we don't lose visibility, but the
    handler swallows it — the alternative is Probot re-running a
    handler that already posted comments / created issues / enqueued
    work.
  - issue_comment.created: surgical fix — every auth-failure return
    (10 sites: requireOrgMember/requireAllowedUser, /allow-merge-commit
    admin check, /review-pr not-a-PR check) now marks before returning.
    Free-text comments that don't match any slash command stay
    unmarked (preserves existing dedup-skip behaviour for common case).

Test plan:
  - 4 new tests:
    - issues.opened marks even when octokit.request throws
    - /sync-all-repos marks on non-membership rejection
    - /sync-all-repos marks on not-allowed-user rejection
    - /review-pr marks on not-a-PR rejection
  - npm test → 837 pass (was 834)
  - npm run lint → clean

Risk: low — behaviour change is narrow (paths that already had visible
side effects now also mark dedup state). No paths that previously
marked stop marking. The handler now swallows exceptions in
issues.opened instead of letting them propagate to Probot — but the
old behaviour was Probot logging + retrying, which IS the bug.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant