Skip to content

[test] Add tests for server.sysListServersHandler - #16868

Merged
lpcox merged 1 commit into
mainfrom
test-coverage-sys-list-servers-c3d739e41fea2379
Nov 19, 2026
Merged

lpcox merged 1 commit into
mainfrom
test-coverage-sys-list-servers-c3d739e41fea2379

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Function Analyzed

  • Package: internal/server
  • Function: sysListServersHandler
  • Previous coverage: 66.7%
  • New coverage: 100.0%
  • Complexity: Medium — the handler resolves request context, validates or creates a session, converts validation failures to MCP error results, and delegates successful calls to the system-tool logger.

Why This Function?

The full coverage report identified sysListServersHandler as 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 inside requireSession; the added defensive guard makes the invalid state fail closed and allows the handler's existing error-result behavior to be tested.

Tests Added

  • Added a test for an uninitialized session store.
  • Verified the handler returns a non-nil, error-marked MCP result, no data payload, and the expected error.
  • Preserved and revalidated normal, reused-session, default-session, and session-directory-failure paths.

Coverage Report

Before: 97.6% overall; sysListServersHandler 66.7%
After:  97.7% overall; sysListServersHandler 100.0%
Improvement: +0.1 percentage points overall; +33.3 percentage points for the target function

Test Execution

Passed:

go test -v ./internal/server -run '^TestSysListServersHandler'
go test -coverprofile=coverage.out ./...
make agent-finished (format, build, Go lint stage, Go unit tests, Go integration tests)

The Rust guard stage of make agent-finished was blocked by the runner's TLS certificate mismatch while downloading serde; an offline retry confirmed the dependency is not cached. The repository's Go lint stage also reported that golangci-lint is not installed and skipped that optional check.

Warning

Firewall blocked 4 domains

The following domains were blocked by the firewall during workflow execution:

  • example.com
  • nonexistent.local
  • slow.example.com
  • thishostdoesnotexist12345.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"
    - "nonexistent.local"
    - "slow.example.com"
    - "thishostdoesnotexist12345.com"

See Network Configuration for more information.

Generated by Test Coverage Improver · copilot · routed: gpt56 xhigh · ~12 AIC · ⊞ 5K · ◷

@lpcox
lpcox marked this pull request as ready for review November 19, 2026 22:45
Copilot AI adaptive review requested due to automatic review settings November 19, 2026 22:45

Copilot AI 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.

🟢 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)

@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default AWF (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads (list_issues, list_pull_requests, get_file_contents, list_commits) data returned ALLOWED ✅
B MCP writes (add_issue_comment/star_repository/issue_write/create_branch/create_or_update_file/create_pull_request) all 6 tools absent from catalog (only 23 read-only tools exposed) BLOCKED ⚠️
C CLI reads (same github CLI proxy) data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) not attempted — gh unauthenticated (gh auth status: not logged in) BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) not attempted — same gh auth gap BLOCKED ⚠️

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 GITHUB_READ_ONLY=1), so the gateway's own DIFC/guard write-blocking layer was never exercised. Parts D/E are inconclusive because the gh CLI was not authenticated in this job, so the token-scope write boundary could not be independently validated. Full detail in /tmp/gh-aw/agent/readonly-stress-44568408270.txt.

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@lpcox
lpcox merged commit 3e272ff into main Nov 19, 2026
26 checks passed
@lpcox
lpcox deleted the test-coverage-sys-list-servers-c3d739e41fea2379 branch November 19, 2026 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants