Skip to content

fix(github): skip issues opened by the configured app bot - #1281

Merged
tinsever merged 1 commit into
usekaneo:mainfrom
Franz1241:t3code/2b016d39
May 28, 2026
Merged

fix(github): skip issues opened by the configured app bot#1281
tinsever merged 1 commit into
usekaneo:mainfrom
Franz1241:t3code/2b016d39

Conversation

@Franz1241

@Franz1241 Franz1241 commented May 22, 2026

Copy link
Copy Markdown
Contributor

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.opened webhook 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:

  1. I create a Kaneo task, for example ORA-4.
  2. Kaneo creates a GitHub issue for that task.
  3. GitHub sends an issues.opened webhook.
  4. Kaneo creates another task, for example ORA-5, from that same issue.
  5. Both Kaneo tasks end up linked to the same GitHub issue.
  6. If "comment Kaneo link on new issues" is enabled, Kaneo comments on the GitHub issue with the duplicate task link instead of the original task link.

In my case, the duplicate task description included the original task id, which made the loop visible:

Task: <original Kaneo task id>

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:

  • Kaneo task → GitHub issue
  • GitHub manually-created issue → Kaneo task

But this loop should be prevented:

  • Kaneo task → GitHub issue → Kaneo duplicate task

Root cause

The issues.opened webhook 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, ignore issues.opened webhooks when the issue author matches the configured GitHub App bot:

const appName = process.env.GITHUB_APP_NAME;
if (appName && issue.user?.login === `${appName}[bot]`) {
  console.log(
    `Issue #${issue.number} was created by the configured GitHub App, skipping task creation`,
  );
  return;
}

This is intentionally small and avoids a database migration. It preserves the bidirectional sync model:

  • Kaneo-created tasks can still create GitHub issues.
  • Manually-created GitHub issues can still create Kaneo tasks.
  • GitHub webhook retries are still covered by the existing external-link lookup.
  • Self-created GitHub issues no longer get imported back into Kaneo as duplicate tasks.

When GITHUB_APP_NAME is 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_NAME rather than hardcoding any particular app slug.

Test plan

  • Create a Kaneo task in a project with a GitHub integration → only one Kaneo task exists after the webhook fires.
  • Open an issue manually in the GitHub UI → Kaneo still creates a task for it.
  • Replay a duplicate issues.opened webhook for an existing linked issue → existing external-link check still skips it.
  • Unset GITHUB_APP_NAME → behavior reverts to the prior external-link-only path.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Issues opened by the configured GitHub App bot are now skipped from task creation and linking logic.

Review Change Stack

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>
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Review Summary by Qodo

Skip issues opened by configured GitHub App bot

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• 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
Diagram
flowchart 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

Loading

File Changes

1. apps/api/src/plugins/github/webhooks/issue-opened.ts 🐞 Bug fix +8/-0

Add GitHub App bot author detection

• Added check to identify issues created by the configured GitHub App bot
• Skips task creation when issue author matches ${GITHUB_APP_NAME}[bot] pattern
• Logs when an issue is skipped due to bot authorship
• Preserves existing external-link lookup as fallback when GITHUB_APP_NAME is unset

apps/api/src/plugins/github/webhooks/issue-opened.ts


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented May 22, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0)

Grey Divider


Remediation recommended

1. Docs out of date 🐞 Bug ⚙ Maintainability
Description
handleIssueOpened now uses GITHUB_APP_NAME to skip importing issues opened by the app bot, but
the docs still describe this variable as only being used for generating installation URLs. This
mismatch can lead to operators enabling it (as recommended) without realizing it will cause some
GitHub issues to be ignored.
Code

apps/api/src/plugins/github/webhooks/issue-opened.ts[R42-48]

Evidence
The webhook handler now uses GITHUB_APP_NAME as a runtime filter, while multiple docs pages still
state it’s only for installation URLs, so the documented contract no longer matches runtime
behavior.

apps/api/src/plugins/github/webhooks/issue-opened.ts[40-49]
apps/docs/core/installation/environment-variables.mdx[98-108]
apps/docs/core/integrations/github/configuration.mdx[17-46]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`GITHUB_APP_NAME` is documented as a UI-only variable (installation links), but it now changes webhook import behavior by skipping `issues.opened` events authored by `${GITHUB_APP_NAME}[bot]`. Update the docs so operators understand this side effect and can troubleshoot “missing imports”.

## Issue Context
This behavior is triggered only when `GITHUB_APP_NAME` is set, and it returns early before integration lookup/external-link checks.

## Fix Focus Areas
- apps/docs/core/installation/environment-variables.mdx[98-108]
- apps/docs/core/integrations/github/configuration.mdx[13-46]
- apps/api/src/plugins/github/webhooks/issue-opened.ts[40-49]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Advisory comments

2. Ambiguous skip logging 🐞 Bug ◔ Observability
Description
The new bot-skip log line only includes Issue #<number>, which is ambiguous across repositories
and omits which bot login matched. This makes it harder to diagnose why an import was skipped when
multiple repos are integrated.
Code

apps/api/src/plugins/github/webhooks/issue-opened.ts[R44-46]

Evidence
The handler destructures repository (including full_name) but the skip log prints only the issue
number, even though the missing context is readily available.

apps/api/src/plugins/github/webhooks/issue-opened.ts[40-46]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The bot-skip log message lacks repository context and the actual actor login, making debugging ambiguous in multi-repo environments.

## Issue Context
`repository.full_name` and `issue.user?.login` are already available in scope.

## Fix Focus Areas
- apps/api/src/plugins/github/webhooks/issue-opened.ts[40-48]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d5861f99-5866-40a2-a86d-f7912ad5f865

📥 Commits

Reviewing files that changed from the base of the PR and between 0f39464 and 9078121.

📒 Files selected for processing (1)
  • apps/api/src/plugins/github/webhooks/issue-opened.ts

📝 Walkthrough

Walkthrough

The handleIssueOpened webhook handler adds an early guard that checks process.env.GITHUB_APP_NAME and exits immediately if the issue author is the configured GitHub App bot user. This prevents duplicate task creation when the bot itself opens issues.

Changes

Issue-opened webhook bot filtering

Layer / File(s) Summary
GitHub App bot detection guard
apps/api/src/plugins/github/webhooks/issue-opened.ts
The function reads the configured GitHub App name from the environment and returns early if the issue author matches the bot user pattern (${appName}[bot]), skipping task creation and linking logic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding logic to skip issues opened by the configured GitHub App bot, which directly addresses the root cause of the duplicate task issue.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Franz1241

Copy link
Copy Markdown
Contributor Author

Hey @tinsever, sorry to bother you but could you please take a look at this tiny bug fix regarding sync logic on Github integration?

@tinsever

Copy link
Copy Markdown
Member

Sure :). No worries, feel free to ping whenever feels needed.

@Asynchronite Asynchronite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!
Have my pointless stamp of approval 😅

@tinsever
tinsever merged commit 791cd25 into usekaneo:main May 28, 2026
8 checks passed
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.

3 participants