Add debug instrumentation to mcpresult content parsing and extraction#7698
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix Go Logger Enhancement workflow failure
Add debug instrumentation to mcpresult content parsing and extraction
Jun 18, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds debug-level instrumentation to the internal/mcpresult helpers used to normalize MCP “content” arrays and extract concatenated text, aiming to improve observability of tool-result parsing without changing behavior.
Changes:
- Added a package-scoped debug logger (
logMCPResult) tointernal/mcpresult/mcpresult.go. - Emitted debug logs at key decision points in
NormalizeContentItemsandExtractTextContent. - Added a new unit test intended to validate extraction behavior with debug logging enabled.
Show a summary per file
| File | Description |
|---|---|
| internal/mcpresult/mcpresult.go | Adds a namespace-scoped debug logger and instrumentation around content normalization/text extraction paths. |
| internal/mcpresult/text_content_test.go | Adds a new test case that sets DEBUG=mcpresult:* and validates extraction output. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
Comment on lines
+378
to
+382
| func TestExtractTextContent_WithDebugLoggingEnabled(t *testing.T) { | ||
| t.Setenv("DEBUG", "mcpresult:*") | ||
|
|
||
| got := ExtractTextContent(map[string]interface{}{ | ||
| "content": []interface{}{ |
Collaborator
|
@copilot address review feedback |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Go Logger Enhancement workflow run failed before it could open a PR, leaving the intended
mcpresultlogging updates unapplied. This PR applies that missing enhancement directly in code with minimal scope.What changed
internal/mcpresult/mcpresult.go:var logMCPResult = logger.New("mcpresult:mcpresult")NormalizeContentItems(input type, normalization path, item counts, unsupported type)ExtractTextContent(content presence, normalization failure path, item processing count, output length)Behavioral intent
logger.New("pkg:filename")conventions.Test update after review feedback
TestExtractTextContent_WithDebugLoggingEnabledfrominternal/mcpresult/text_content_test.gobecause per-testt.Setenv("DEBUG", ...)cannot reconfigure the already-initialized package logger and the test was misleading.