Skip to content

Add debug instrumentation to mcpresult content parsing and extraction#7698

Merged
lpcox merged 4 commits into
mainfrom
copilot/go-logger-enhancement-fix
Jun 18, 2026
Merged

Add debug instrumentation to mcpresult content parsing and extraction#7698
lpcox merged 4 commits into
mainfrom
copilot/go-logger-enhancement-fix

Conversation

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

The Go Logger Enhancement workflow run failed before it could open a PR, leaving the intended mcpresult logging updates unapplied. This PR applies that missing enhancement directly in code with minimal scope.

  • What changed

    • Added a package logger in internal/mcpresult/mcpresult.go:
      • var logMCPResult = logger.New("mcpresult:mcpresult")
    • Added debug logs around key decision points in:
      • NormalizeContentItems (input type, normalization path, item counts, unsupported type)
      • ExtractTextContent (content presence, normalization failure path, item processing count, output length)
  • Behavioral intent

    • Improves observability of MCP tool-result parsing/extraction paths without altering return semantics.
    • Keeps logging side-effect free and aligned with existing logger.New("pkg:filename") conventions.
  • Test update after review feedback

    • Removed TestExtractTextContent_WithDebugLoggingEnabled from internal/mcpresult/text_content_test.go because per-test t.Setenv("DEBUG", ...) cannot reconfigure the already-initialized package logger and the test was misleading.
var logMCPResult = logger.New("mcpresult:mcpresult")

func NormalizeContentItems(contentVal interface{}) ([]map[string]interface{}, bool) {
    logMCPResult.Printf("Normalizing MCP content items from type %T", contentVal)
    // ...
}

GitHub Advanced Security started work on behalf of lpcox June 18, 2026 00:47 View session
GitHub Advanced Security finished work on behalf of lpcox June 18, 2026 00:49
Copilot AI changed the title [WIP] Fix Go Logger Enhancement workflow failure Add debug instrumentation to mcpresult content parsing and extraction Jun 18, 2026
Copilot finished work on behalf of lpcox June 18, 2026 00:55
Copilot AI requested a review from lpcox June 18, 2026 00:55
GitHub Advanced Security started work on behalf of lpcox June 18, 2026 00:56 View session
GitHub Advanced Security started work on behalf of lpcox June 18, 2026 00:57 View session
GitHub Advanced Security finished work on behalf of lpcox June 18, 2026 00:57
GitHub Advanced Security finished work on behalf of lpcox June 18, 2026 00:58
@lpcox lpcox marked this pull request as ready for review June 18, 2026 01:07
Copilot AI review requested due to automatic review settings June 18, 2026 01:07

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

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) to internal/mcpresult/mcpresult.go.
  • Emitted debug logs at key decision points in NormalizeContentItems and ExtractTextContent.
  • 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 thread internal/mcpresult/text_content_test.go Outdated
Comment on lines +378 to +382
func TestExtractTextContent_WithDebugLoggingEnabled(t *testing.T) {
t.Setenv("DEBUG", "mcpresult:*")

got := ExtractTextContent(map[string]interface{}{
"content": []interface{}{
@lpcox

lpcox commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

GitHub Advanced Security started work on behalf of lpcox June 18, 2026 01:16 View session

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

Addressed in 9b3d352. I removed TestExtractTextContent_WithDebugLoggingEnabled from internal/mcpresult/text_content_test.go since t.Setenv("DEBUG", ...) cannot affect the already-initialized package logger and the test was misleading.

GitHub Advanced Security finished work on behalf of lpcox June 18, 2026 01:17
Copilot finished work on behalf of lpcox June 18, 2026 01:18
@lpcox lpcox merged commit 096fba4 into main Jun 18, 2026
33 checks passed
@lpcox lpcox deleted the copilot/go-logger-enhancement-fix branch June 18, 2026 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants