Skip to content

fix(mcp): add return after t.Fatal to satisfy staticcheck SA5011#141

Merged
greynewell merged 1 commit intomainfrom
fix/server-test-sa5011
Apr 21, 2026
Merged

fix(mcp): add return after t.Fatal to satisfy staticcheck SA5011#141
greynewell merged 1 commit intomainfrom
fix/server-test-sa5011

Conversation

@greynewell
Copy link
Copy Markdown
Contributor

@greynewell greynewell commented Apr 21, 2026

Summary

  • Adds an unreachable return after each t.Fatal call in three server_test.go tests where staticcheck SA5011 was flagging a potential nil pointer dereference
  • staticcheck does not recognise t.Fatal as goroutine-terminating, so it considers a pointer that was checked for nil and then dereferenced in the next block as potentially nil — the return satisfies the analyser without changing behaviour

Affected tests:

  • TestDispatch_UnknownMethod
  • TestDispatch_ToolsCall_UnknownTool
  • TestHandleToolCall_ParseError

Test plan

  • make lint — 0 issues
  • go test ./internal/mcp/... — all tests pass

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Improved test reliability with additional error handling checks.

staticcheck SA5011 flags pointer dereferences that follow a nil check
guarded only by t.Fatal, which it does not recognise as
goroutine-terminating. Adding an unreachable return satisfies the
analyser without changing test behaviour.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b7ec1874-691a-4042-8e35-76bdd1cd2ffa

📥 Commits

Reviewing files that changed from the base of the PR and between fa3bb36 and ea167af.

📒 Files selected for processing (1)
  • internal/mcp/server_test.go

Walkthrough

Three test cases in the server test file now include early return statements after asserting that an rpcErr is unexpectedly nil. This prevents subsequent code from attempting to access properties of a null error object, avoiding potential nil pointer issues during test execution.

Changes

Cohort / File(s) Summary
Test Safety Guard
internal/mcp/server_test.go
Added early return statements in three test cases (TestDispatch_UnknownMethod, TestDispatch_ToolsCall_UnknownTool, TestHandleToolCall_ParseError) immediately after nil assertions to prevent accessing properties on a null error.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🛡️ Three guards now stand so tall and true,
When errors vanish in the test zoo,
Early returns say "stop right here!"
No nil pointer panics, crystal clear. ✨


Here's the vibe: Think of this like a safety checkpoint. Imagine you're checking if a package arrived (rpcErr), and if it didn't arrive, you write a note and bounce—you don't try to open it and look inside. That's what these early returns do. Before, the tests would keep going and try to access rpcErr.Code even when there was no error object, which would cause things to blow up. Now? Clean exit. Mission accomplished! 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding return statements after t.Fatal calls to satisfy staticcheck SA5011 warnings.
Description check ✅ Passed The description covers the what, why, and test plan with clear details about the changes and their motivation, though it uses a custom format rather than the template structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/server-test-sa5011

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

@greynewell greynewell merged commit d8429d8 into main Apr 21, 2026
7 checks passed
@greynewell greynewell deleted the fix/server-test-sa5011 branch April 21, 2026 20:31
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