fix(github): skip issues opened by the configured app bot - #1281
Conversation
The issues.opened webhook treated Kaneo-created issues as manual ones
and created duplicate tasks when the webhook arrived before the
task-to-issue external link was persisted. Skip when the issue author
matches `${GITHUB_APP_NAME}[bot]`; the existing external-link lookup
remains the fallback when GITHUB_APP_NAME is unset.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Review Summary by QodoSkip issues opened by configured GitHub App bot
WalkthroughsDescription• Prevents duplicate Kaneo tasks from GitHub webhook retries • Skips issue-opened webhooks when author is configured GitHub App bot • Uses GITHUB_APP_NAME environment variable for bot identification • Preserves bidirectional sync for manually-created GitHub issues Diagramflowchart LR
A["Kaneo Task Created"] -->|"Creates"| B["GitHub Issue"]
B -->|"Webhook Fired"| C{"Issue Author<br/>is App Bot?"}
C -->|"Yes"| D["Skip Task Creation"]
C -->|"No"| E["Create Kaneo Task"]
F["Manual GitHub Issue"] -->|"Webhook Fired"| E
File Changes1. apps/api/src/plugins/github/webhooks/issue-opened.ts
|
Code Review by Qodo
1. Docs out of date
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe ChangesIssue-opened webhook bot filtering
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hey @tinsever, sorry to bother you but could you please take a look at this tiny bug fix regarding sync logic on Github integration? |
|
Sure :). No worries, feel free to ping whenever feels needed. |
Problem
When I create a Kaneo task in a project connected to a GitHub repository, Kaneo correctly creates a GitHub issue for that task. However, GitHub then sends an
issues.openedwebhook back to Kaneo. The webhook handler can treat that issue as if it was manually created in GitHub, so it creates a second Kaneo task from the same GitHub issue.The result is:
ORA-4.issues.openedwebhook.ORA-5, from that same issue.In my case, the duplicate task description included the original task id, which made the loop visible:
Expected behavior
Kaneo should not create a new task from a GitHub issue that was created by Kaneo itself.
The intended sync behavior should remain:
But this loop should be prevented:
Root cause
The
issues.openedwebhook handler currently relies on checking whether an external link already exists for the incoming GitHub issue.That is not always enough. If the GitHub webhook is delivered before the original task-to-issue external link is available, Kaneo sees no existing link and creates a duplicate task.
Fix
In
apps/api/src/plugins/github/webhooks/issue-opened.ts, ignoreissues.openedwebhooks when the issue author matches the configured GitHub App bot:This is intentionally small and avoids a database migration. It preserves the bidirectional sync model:
When
GITHUB_APP_NAMEis unset, the existing external-link check remains the fallback behavior, so this change is safe for instances that haven't configured the optional app name.The check is generalized and not specific to any deployment — it uses the configured
GITHUB_APP_NAMErather than hardcoding any particular app slug.Test plan
issues.openedwebhook for an existing linked issue → existing external-link check still skips it.GITHUB_APP_NAME→ behavior reverts to the prior external-link-only path.🤖 Generated with Claude Code
Summary by CodeRabbit