Repository navigation
[test] Add tests for guard.tryCallWasmFunction - #17192
Conversation
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the added WebAssembly memory-error regression tests.
No open issues 🎉
What changed in this PR
Adds focused tests for internal/guard’s tryCallWasmFunction, strengthening coverage of WebAssembly memory-handling failures without changing production code.
Changes:
- Adds real WASM fixtures for missing memory, memory-growth failure, and invalid allocator output.
- Adds four tests covering direct-memory and allocator-path errors, checking returned values and error messages.
- Reports function coverage increasing from 86.0% to 95.3%.
| File | Description |
|---|---|
| internal/guard/wasm_exec_coverage_test.go | Adds WASM fixtures and four memory-error regression tests. |
Review effort: Balanced (adaptive)
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE ( No write leaked in any part. Independent gateway-layer write enforcement is covered separately by internal/guard and internal/difc unit tests and the proxy-level read-filtering smoke test.
|
Function analyzed
internal/guardtryCallWasmFunctionWhy this function
The coverage report had no substantive function below 50%; the only 0% entry was an intentionally empty logger callback.
tryCallWasmFunctionwas the strongest meaningful target because it had materially lower coverage than most core code while coordinating WASM allocation, memory growth, input writes, and fallback behavior.Tests added
The tests use real wazero modules and assert returned values and error messages without introducing mocks for wazero's internal memory interface.
Verification
go test ./internal/guard -run 'TestTryCallWasmFunction_(MissingMemory|MemoryGrowthFails|AllocatorInputWriteFails|DirectInputWriteFails)' -count=1 -v— passedgo test -coverprofile=... ./...— passed; overall coverage remains 97.6%make agent-finished— formatting, build, Go tests, and integration tests passed; golangci-lint was unavailable and skipped by the repository Makefileserdeis not cachedNo production code was changed.
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.