Skip to content

[log] Add debug logging to server middleware helpers - #11519

Merged
lpcox merged 1 commit into
mainfrom
log/server-middleware-1787182368-a450ac38e043682b
Aug 20, 2026
Merged

[log] Add debug logging to server middleware helpers#11519
lpcox merged 1 commit into
mainfrom
log/server-middleware-1787182368-a450ac38e043682b

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Adds debug logging to internal/server/middleware.go, reusing the existing logServerHelpers logger (server:helpers namespace) that is already used elsewhere in the package.

Changes

  • WithOTELTracing: logs the tag when a handler is wrapped with an OTEL tracing span.
  • buildMCPHandler: logs the log tag, backend ID, and session timeout when constructing the MCP handler stack, plus a log line when backend registration is required for a given backendID.

These additions help trace which middleware/handler configuration is applied per request path (routed vs. unified mode) when troubleshooting session or backend-registration issues.

Validation

  • gofmt -l internal/server/middleware.go — no output (already formatted)
  • go vet ./internal/server/... — passed
  • go test ./internal/server/... — passed (ok)
  • go build -o awmg . — succeeded

No existing logging was duplicated; no side-effecting log arguments were introduced.

Generated by Go Logger Enhancement · auto · 128.4 AIC · ⊞ 12.8K ·

Add logServerHelpers debug logging to WithOTELTracing and
buildMCPHandler in internal/server/middleware.go to aid
troubleshooting of the HTTP middleware/handler construction chain.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added automation enhancement New feature or request labels Aug 19, 2026
@lpcox
lpcox marked this pull request as ready for review August 20, 2026 09:48
Copilot AI balanced review requested due to automatic review settings August 20, 2026 09:48

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.

Pull request overview

Adds targeted debug logging for server middleware and MCP handler construction.

Changes:

  • Logs OTEL tracing wrapper tags.
  • Logs handler configuration and backend-registration requirements.
Show a summary per file
File Description
internal/server/middleware.go Adds debug diagnostics for middleware and handler setup.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — gVisor

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: gVisor (runsc) kernel-level isolation

Part Surface Op Result Expected Status
A MCP list_issues data returned ALLOWED
A MCP list_pull_requests data returned ALLOWED
A MCP get_file_contents data returned ALLOWED
A MCP list_commits data returned ALLOWED
B MCP writes (reaction/star/issue/comment/branch/file/PR) tool absent from catalog BLOCKED ⚠️
C CLI list_issues (github CLI) data returned ALLOWED
D CLI REST writes gh unauthenticated BLOCKED ⚠️
E CLI GraphQL mutations gh unauthenticated BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Part B: The backend runs with GITHUB_READ_ONLY=1 (gh-aw framework default), so all 7 write tools (add_issue_comment, star_repository, issue_write, create_branch, create_pull_request, create_or_update_file, and add_issue_comment body variant) were absent from the MCP tool catalog (23 read-only tools exposed). All write attempts returned Error [-32602]: unknown tool. This confirms gh-aw's own defense-in-depth but does not independently exercise mcpg's DIFC/guard enforcement — recorded as INCONCLUSIVE per test plan.

⚠️ Parts D & E: gh is not authenticated in this environment (no GH_TOKEN). All CLI REST write and GraphQL mutation attempts returned "not logged into any GitHub hosts." Gateway token-scope boundary cannot be validated in this run — all D/E rows are INCONCLUSIVE.

No write leaked. No FAIL condition triggered.

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

@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — default AWF

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 list_issues 3 issues returned ALLOWED
A MCP list_pull_requests 3 PRs returned ALLOWED
A MCP get_file_contents (README.md) content returned ALLOWED
A MCP list_commits 3 commits returned ALLOWED
B MCP add_issue_comment (reaction) unknown tool [-32602] BLOCKED ⚠️
B MCP star_repository unknown tool [-32602] BLOCKED ⚠️
B MCP issue_write (create) unknown tool [-32602] BLOCKED ⚠️
B MCP create_branch unknown tool [-32602] BLOCKED ⚠️
B MCP create_or_update_file unknown tool [-32602] BLOCKED ⚠️
B MCP create_pull_request unknown tool [-32602] BLOCKED ⚠️
C CLI list_issues (github CLI) data returned ALLOWED
C CLI get_file_contents (github CLI) data returned ALLOWED
C CLI list_pull_requests (github CLI) data returned ALLOWED
C CLI list_commits (github CLI) data returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) gh unauthenticated BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh unauthenticated BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Part B — INCONCLUSIVE: All 6 targeted write tools (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) were absent from the MCP catalog — the gateway backend exposes only 23 read-only tools (list_issues, list_pull_requests, get_file_contents, etc.) because gh-aw unconditionally sets GITHUB_READ_ONLY=1 before launching the GitHub MCP server. Tool-not-found errors prove backend-level defense-in-depth, not independent mcpg DIFC/guard enforcement (per the architectural note in the test plan).

⚠️ Parts D/E — INCONCLUSIVE: gh CLI is not authenticated in this environment (GH_TOKEN not set). All REST write and GraphQL mutation attempts fail with an authentication error, not a permission error. The token-scope boundary cannot be confirmed in this run.

No writes leaked. All reads succeeded. The absence of any write leaking is a positive signal, but the two INCONCLUSIVE surfaces mean gateway-level enforcement on those paths was not independently exercised this run.

References: §32313773293

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

@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — docker-sbx

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: docker-sbx (KVM-isolated microVM)

Part Surface Op Result Expected Status
A MCP reads (issues/PRs/file/commits) data returned ALLOWED
B MCP writes (reaction/star/issue/comment/branch/file/PR) all tools absent from catalog BLOCKED ⚠️
C CLI reads (issues/file) data returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) Bad credentials (gh unauthenticated) BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) Bad credentials (gh unauthenticated) BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Gap details:

  • Part B: All 6 targeted write tools (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) were absent from the MCP tool catalog (backend launched with GITHUB_READ_ONLY=1). This confirms gh-aw's defense-in-depth; it does NOT independently confirm mcpg's DIFC/guard enforcement layer, since no write-capable tool call could reach the gateway's own blocking logic.
  • Parts D & E: gh reports GH_TOKEN is invalid — token authentication failed. All REST/GraphQL write attempts returned 401 Bad credentials. This is not evidence of mcpg blocking; it cannot confirm the token-scope boundary for this runtime.

No writes leaked. No FAIL detected. INCONCLUSIVE due to structural gaps in observability, not a security regression.

🔒 mcpg read-only stress (docker-sbx runtime) by Read-Only Stress: docker-sbx runtime

@lpcox
lpcox merged commit ddd0e88 into main Aug 20, 2026
35 checks passed
@lpcox
lpcox deleted the log/server-middleware-1787182368-a450ac38e043682b branch August 20, 2026 16:03
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