Skip to content

fix(teammcp): guard nil provider in handleTeamActionRelayEvents#685

Merged
najmuzzaman-mohammad merged 3 commits into
nex-crm:mainfrom
CharlieKerfoot:fix/handleteamactionrelayeven
May 7, 2026
Merged

fix(teammcp): guard nil provider in handleTeamActionRelayEvents#685
najmuzzaman-mohammad merged 3 commits into
nex-crm:mainfrom
CharlieKerfoot:fix/handleteamactionrelayeven

Conversation

@CharlieKerfoot

@CharlieKerfoot CharlieKerfoot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

handleTeamActionRelayEvents in internal/teammcp/actions.go:747 called externalActionProvider.ListRelayEvents directly, panicking with a nil pointer dereference when no external provider was configured. Every sibling handler routes through selectedActionProvider, which returns a typed error in that case. This was the only one that didn't.

Fix

Resolve the provider via selectedActionProvider(action.CapabilityRelayEvents) first and surface its error through toolError, matching the pattern used by the other relay handlers. The ListRelayEvents call now goes through the resolved provider.

Tests

bash scripts/test-go.sh passes.

Summary by CodeRabbit

  • Refactor
    • Improved handling of team action relay events by adding explicit provider resolution and error handling before listing events. This change centralizes provider selection and enhances reliability of event listing operations without altering user-facing behavior.

@CharlieKerfoot CharlieKerfoot requested review from a team and FranDias as code owners May 6, 2026 15:39
@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The handleTeamActionRelayEvents function now resolves the action provider via selectedActionProvider(action.CapabilityRelayEvents), returns an error if resolution fails, and calls the resolved provider's ListRelayEvents with the same request options previously used.

Changes

Provider Resolution in Relay Events Handler

Layer / File(s) Summary
Provider Resolution & Error Handling
internal/teammcp/actions.go
handleTeamActionRelayEvents now calls selectedActionProvider(action.CapabilityRelayEvents) to obtain a provider, checks/returns an error on failure, and invokes provider.ListRelayEvents with the same pagination/filter options previously passed to externalActionProvider.ListRelayEvents.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐇 I hopped through code in search of a clue,
Found a provider hiding where globals once grew.
Now selection is clever and errors are caught,
Relay events listed the way they were taught.

🚥 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 nil provider guard in handleTeamActionRelayEvents function to prevent panics.
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

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.

@najmuzzaman-mohammad

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@najmuzzaman-mohammad najmuzzaman-mohammad 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.

CodeRabbit CI pass:17, no actionable comments. LGTM.

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/teammcp/actions.go (1)

1125-1125: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Apply the same nil-guard pattern here.

This handler still directly accesses externalActionProvider.GetRelayEvent without nil checking, causing the same panic risk that was just fixed in handleTeamActionRelayEvents. Apply the same pattern for consistency.

🛡️ Proposed fix
 func handleTeamActionRelayEvent(ctx context.Context, _ *mcp.CallToolRequest, args TeamActionRelayEventArgs) (*mcp.CallToolResult, any, error) {
+	provider, err := selectedActionProvider(action.CapabilityRelayEvents)
+	if err != nil {
+		return toolError(err), nil, nil
+	}
-	result, err := externalActionProvider.GetRelayEvent(ctx, args.ID)
+	result, err := provider.GetRelayEvent(ctx, args.ID)
 	if err != nil {
 		return toolError(err), nil, nil
 	}
🤖 Prompt for 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.

In `@internal/teammcp/actions.go` at line 1125, The call to
externalActionProvider.GetRelayEvent should be guarded against
externalActionProvider being nil to avoid a panic; follow the same nil-guard
pattern used in handleTeamActionRelayEvents by first checking if
externalActionProvider == nil and returning an appropriate error (or empty
response) before calling externalActionProvider.GetRelayEvent, and update the
handler around the GetRelayEvent invocation (the variables result, err)
accordingly.
🤖 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.

Outside diff comments:
In `@internal/teammcp/actions.go`:
- Line 1125: The call to externalActionProvider.GetRelayEvent should be guarded
against externalActionProvider being nil to avoid a panic; follow the same
nil-guard pattern used in handleTeamActionRelayEvents by first checking if
externalActionProvider == nil and returning an appropriate error (or empty
response) before calling externalActionProvider.GetRelayEvent, and update the
handler around the GetRelayEvent invocation (the variables result, err)
accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 02c50670-f720-447a-90f0-6fe10ad9d1c5

📥 Commits

Reviewing files that changed from the base of the PR and between 7a1634b and 52d1b9f.

📒 Files selected for processing (1)
  • internal/teammcp/actions.go

@najmuzzaman-mohammad najmuzzaman-mohammad merged commit 6cdbb9f into nex-crm:main May 7, 2026
17 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.

2 participants