[MM-69266] Fix false "No webhook was found" warning when only an org-…#1027
Conversation
…level webhook exists
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesWebhook Existence Check Refactor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 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 docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@server/plugin/command.go`:
- Around line 455-458: The error handling block checks for cErr but then uses
listErr in both the log message and return statement, which could be nil and
cause a panic. In the condition where cErr is non-nil, replace all references to
listErr with cErr in the processLogger.Warn call and the return statement to log
and return the actual error from the useGitHubClient operation.
- Around line 466-468: The pagination logic at line 466-468 checks resp.NextPage
without first verifying that resp itself is not nil, which can cause a nil
pointer dereference when the GitHub API returns a nil response in edge cases.
Update the condition to include a nil check for resp before accessing its
NextPage property, following the pattern already established in sla_digest.go
where both conditions are checked together: first verify resp is not nil, then
check if resp.NextPage equals zero.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8c7c4ebc-4d4e-4db0-9a05-566a3b613784
📒 Files selected for processing (1)
server/plugin/command.go
avasconcelos114
left a comment
There was a problem hiding this comment.
Changes are looking good! I just have one possible edge-case that might need to be confirmed
| return true, nil | ||
| } | ||
|
|
||
| found, err = p.anyHookMatchesSiteURL(userInfo, owner, repo, siteURL, listOrgHooks) |
There was a problem hiding this comment.
We may have to skip this org fallback if the repository's owner is a user instead of an org, otherwise we may get a false-positive where the 404 response from the listOrgHooks request cascades into isWebhookListAccessError being true and returning true instead of leaving it to the final return found, nil which was going to be correctly marked as false since the user hadn't set up webhooks for their personal repo
Summary
When a channel is subscribed to a specific repository via
/github subscribe owner/repoand webhook delivery is handled by an org level webhook the plugin incorrectly posts:Ticket Link
https://mattermost.atlassian.net/browse/MM-69266
QA
<org>- Settings - Webhooks add a webhook with Payload URLhttps://<mattermost>/plugins/github/webhook./github subscribe <org>/<repo>.Change Impact: 🟡 Medium
Reasoning: This PR changes the logic that determines whether to show a user-facing “No webhook was found” warning during
/github subscribe, specifically treating certain GitHub webhook-list access failures (403/404) during org-hook checks as “configured” so organization-level webhooks are recognized. While it does not alter webhook delivery, it does change the plugin’s behavioral contract for warning/UX decisions in permission-related scenarios.Regression Risk: Moderate—changes are localized to
command.go, but the new fallback/error-handling behavior can affect multiple subscription outcomes (org-owned vs user-owned repos) and the decision to suppress warnings when webhook listing is blocked; while unit tests cover the main org-owned/403 scenario, they don’t exhaustively cover all permission/error variants (e.g., 404 access error vs other errors, pagination edge cases).QA Recommendation: Perform targeted manual QA focused on the subscription warning behavior: (1) repo-level webhook configured only, (2) org-level webhook configured only, (3) org-owned repo where listing org webhooks returns 403/404, (4) confirm no false warning appears in the described reproduction flow. Automated tests added for the core logic; manual QA should be limited to these scenarios due to moderate risk.
Generated by CodeRabbitAI