Repository navigation
[test] Add tests for server.sysListServersHandler - #16868
Conversation
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The review found no active issues, and the change adds explicit handling and test coverage for the uninitialized session-store path while preserving existing session behavior.
No open issues 🎉
What changed in this PR
This PR improves defensive handling and test coverage for an uninitialized session store in sysListServersHandler, ensuring invalid server state returns an MCP error instead of panicking.
Changes:
- Added a nil session-store guard in
requireSession. - Added coverage for the uninitialized-store error path.
- Preserved tests for normal, reused-session, default-session, and directory-failure behavior.
| File | Description |
|---|---|
| internal/server/session.go | Adds a defensive guard that returns an explicit error when the session store is uninitialized. |
| internal/server/session_test.go | Tests the handler's MCP error result for an uninitialized session store while preserving existing session behavior coverage. |
Review effort: Lite (adaptive)
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE No write leaked on any surface. Part B is inconclusive because all targeted write tools were absent from the exposed MCP catalog (gh-aw always launches the backend with
|
Function Analyzed
internal/serversysListServersHandlerWhy This Function?
The full coverage report identified
sysListServersHandleras the lowest-coverage meaningful function after excluding the repository's trivial zero-coverage no-op logger. Its missing branch was the session-validation error path. That path could not be exercised safely because an uninitialized session map would previously panic insiderequireSession; the added defensive guard makes the invalid state fail closed and allows the handler's existing error-result behavior to be tested.Tests Added
Coverage Report
Test Execution
Passed:
The Rust guard stage of
make agent-finishedwas blocked by the runner's TLS certificate mismatch while downloadingserde; an offline retry confirmed the dependency is not cached. The repository's Go lint stage also reported thatgolangci-lintis not installed and skipped that optional check.Warning
Firewall blocked 4 domains
The following domains were blocked by the firewall during workflow execution:
example.comnonexistent.localslow.example.comthishostdoesnotexist12345.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.