Skip to content

fix(mcp): filter debug log lines from audit tool error response#19506

Merged
pelikhan merged 2 commits intomainfrom
copilot/fix-debug-log-in-error
Mar 4, 2026
Merged

fix(mcp): filter debug log lines from audit tool error response#19506
pelikhan merged 2 commits intomainfrom
copilot/fix-debug-log-in-error

Conversation

Copy link
Contributor

Copilot AI commented Mar 4, 2026

When DEBUG=* is set in the MCP server's environment, the audit subprocess inherits it and emits debug initialization logs to stderr. Because the error handler used the full stderr as the MCP error message, callers received a wall of internal diagnostics instead of the actual error.

Changes

  • mcp_tools_privileged.go: Replace strings.TrimSpace(stderr) as mainMsg with a new extractLastConsoleMessage helper. The helper scans stderr lines and returns the last line prefixed with a console symbol (, , , , etc.), falling back to the last non-empty line if none found. Full stderr is still preserved in errorData.stderr.
  • mcp_tools_privileged_test.go: Unit tests for extractLastConsoleMessage covering debug-only output, mixed output, empty input, and multiple console message cases.

BeforemainMsg contained the entire stderr:

failed to audit workflow run: workflow:script_registry Creating new script registry +151ns
workflow:domains Loading ecosystem domains from embedded JSON +760µs
...
✗ failed to fetch run metadata: workflow run 99999999999 not found.

After — only the user-facing console message:

failed to audit workflow run: ✗ failed to fetch run metadata: workflow run 99999999999 not found.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw GO111MODULE 64/bin/go git rev-�� --show-toplevel go (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha --get remote.origin.url /opt/hostedtoolcache/node/24.13.1/x64/bin/node -json GO111MODULE tions/node_modul--show-toplevel node /tmp�� /git/ref/tags/v8 go /usr/bin/git -json GO111MODULE 1/x64/bin/node git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha ithub/workflows/audit-workflows.md k/gh-aw/gh-aw/pkg/cli/actionlint.go 7761935/b397/vet.cfg GOSUMDB GOWORK 64/bin/go /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/compile -o /tmp/go-build3484860492/b001/_pkg_.a -trimpath /usr/bin/gh -p main -lang=go1.25 gh (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json 18462d14 ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE sh (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel go /opt/hostedtoolcache/node/24.13.1/x64/bin/node .js' --ignore-pagit GO111MODULE 64/bin/go node /tmp�� /home/REDACTED/work/gh-aw/gh-aw/.github/workflows/brave.md tDxh6_4/9rUbv3kNTest User /usr/bin/gh -json GO111MODULE 64/bin/go gh (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha pload-artifact/git/ref/tags/v7 go /usr/bin/infocmp 18462d14:pkg/cligit GO111MODULE x_amd64/link infocmp -1 xterm-color x_amd64/link /usr/bin/git "prettier" --chegit GOPROXY ache/go/1.25.0/x--show-toplevel git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha --show-toplevel (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha /tmp/gh-aw-test-runs/20260304-051311-37222/test-2019783519 rev-parse g_.a th .prettierignogit GO111MODULE 64/bin/go git init�� GOMODCACHE go ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -json GO111MODULE de/node/bin/sh ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha --show-toplevel go /usr/bin/git -json GO111MODULE ache/go/1.25.0/x--show-toplevel git rev-�� --show-toplevel go /usr/bin/git 94/001/test-compgit GO111MODULE 64/pkg/tool/linu--show-toplevel git (http block)
  • https://api.github.com/repos/actions/download-artifact/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/download-artifact/git/ref/tags/v8 --jq .object.sha prettier --check ache/go/1.25.0/x64/bin/go **/*.ts **/*.json 18462d14 node /hom�� 1311-37222/test-2524783878/.github/workflows scripts/**/*.js /opt/hostedtoolcache/go/1.25.0/x64/bin/go .prettierignore GO111MODULE 64/bin/go go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/download-artifact/git/ref/tags/v8 --jq .object.sha -json GO111MODULE g_.a GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/download-artifact/git/ref/tags/v8 --jq .object.sha 051322571/001 GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/compile elete GOMOD 66775556ce06bd83--show-toplevel ache/go/1.25.0/x64/pkg/tool/linux_amd64/compile env 7761935/b416/_pkg_.a GO111MODULE 7761935/b416=> GOINSECURE GOMOD GOMODCACHE git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha go1.25.0 -c=4 -nolocalimports -importcfg /tmp/go-build3484860492/b001/importcfg -pack /tmp/go-build3484860492/b001/_testmain.go ules�� -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha -c=4 -nolocalimports -importcfg /tmp/go-build2287761935/b385/importcfg -embedcfg /tmp/go-build2287761935/b385/embedcfg -pack env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha th .prettierignoGOINSECURE GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 1/x64/bin/node GOINSECURE GOMOD igFiles,SwigCXXF/tmp/go-build2287761935/b392/_pkg_.a go (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha --show-toplevel go /usr/bin/git th .prettierignogit GO111MODULE 64/bin/go git conf�� user.name Test User e/git-remote-https -json GO111MODULE 86_64/sh e/git-remote-https (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha /tmp/gh-aw-test-runs/20260304-051311-37222/test-2041707579 rev-parse /usr/bin/git th .prettierignogit GO111MODULE 64/bin/go git init�� GOMODCACHE go /usr/bin/git -json GO111MODULE 1/x64/lib/node_m--show-toplevel git (http block)
  • https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq .object.sha SameOutput3124576825/001/stability-test.md GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 1/x64/bin/node GOINSECURE GOMOD GOMODCACHE git (http block)
  • https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v7
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v7 --jq .object.sha -json 18462d14 ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE sh -c 94/001/test-frontmatter-with-arrays.md GOPROXY ache/go/1.25.0/x64/bin/go GOSUMDB GOWORK 18462d14 node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v7 --jq .object.sha 18462d14:pkg/cli/mcp_tools_privileged.go GO111MODULE 86_64/bash GOINSECURE GOMOD GOMODCACHE node /opt�� prettier --check ache/go/1.25.0/x64/bin/go **/*.ts **/*.json --ignore-path go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v7 --jq .object.sha 18462d14:pkg/cli/mcp_tools_privileged.go GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE sh -c 6825/001/stability-test.md GOPROXY ache/go/1.25.0/x64/bin/go GOSUMDB GOWORK 64/bin/go git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile k/gh�� -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD erignore go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go estl�� -json GO111MODULE n-dir/bash GOINSECURE GOMOD erignore go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 GO111MODULE 64/bin/go GOINSECURE GOMOD ode-gyp-bin/sh go estl�� -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD erignore go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go k/gh�� -json GO111MODULE ndor/bin/bash GOINSECURE GOMOD erignore go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go k/gh�� -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD erignore go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go k/gh�� -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD erignore go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go k/gh�� -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD erignore go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path on' --ignore-patGOINSECURE GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100 GOMOD GOMODCACHE go env leged_test.go GO111MODULE ules/.bin/sh GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 GOMOD GOMODCACHE x_amd64/compile env ty-test.md GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha ty-test.md GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE erignore env -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v2.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE tions/setup/js/node_modules/.binGOMODCACHE GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE ules/.bin/node GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v3.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha -json GO111MODULE utofind GOINSECURE GOMOD GOMODCACHE utofind env -json GO111MODULE tions/setup/node_modules/.bin/noGOMODCACHE GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE erignore env 1925893531/.github/workflows GO111MODULE ndor/bin/git GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE GOMOD GOMODCACHE x_amd64/vet env ck 'scripts/**/*.js' --ignore-pa-c=4 GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build2287761935/b383/cli.test /tmp/go-build2287761935/b383/cli.test -test.testlogfile=/tmp/go-build2287761935/b383/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true GOINSECURE GOMOD GOMODCACHE go env th .prettierignoGOSUMDB GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[cli-tools-test] audit: debug initialization logs leaked in MCP error response for invalid run IDs</issue_title>
<issue_description>## Problem Description

When the audit tool is called with an invalid or non-existent run ID via the MCP server, the error response includes verbose internal debug/initialization log output mixed with the actual error message. The real error is buried at the end of a wall of diagnostic output, making it hard to identify the actual problem.

Tool

  • Tool: audit
  • Interface: agentic-workflows MCP server

Steps to Reproduce

  1. Call the agenticworkflows MCP tool's audit command with a non-existent run ID (e.g., 99999999999)

Expected Behavior

A clean error message like:

✗ workflow run 99999999999 not found. Please verify the run ID is correct and that you have access to the repository
```

## Actual Behavior

The error response from the MCP server includes internal debug initialization logs preceding the actual error:

```
McpError: MCP error -32603: calling "tools/call": failed to audit workflow run: workflow:script_registry Creating new script registry +151ns
workflow:domains Loading ecosystem domains from embedded JSON +760µs
workflow:domains Loaded 31 ecosystem categories +161µs
workflow:expression_patterns Initializing expression pattern regex compilation +911µs
workflow:js Script registration completed (embedded scripts removed) +724µs
workflow:permissions_validation Loading GitHub toolsets permissions from embedded JSON +429µs
workflow:permissions_validation Loaded 19 GitHub toolsets from JSON +159µs
workflow:runtime_definitions Initializing runtime definitions: total_runtimes=11 +590µs
workflow:runtime_definitions Built command to runtime mapping: total_commands=30 +8µs
workflow:runtime_definitions Built action repo to runtime mapping: total_actions=11 +4µs
workflow:scripts Script registration completed (embedded scripts removed) +498µs
cli:mcp Creating MCP command with subcommands +562µs
cli:secrets_command Creating secrets command with subcommands +658µs
workflow:version Setting compiler version: 99b2107 +1ms
workflow:version Setting release build flag: false +5µs
cli:audit Starting audit for workflow run: runID=99999999999, owner=, repo=, jobID=0, stepNumber=0 +916µs
cli:audit Using output directory: /tmp/gh-aw/aw-mcp/logs/run-99999999999 +14µs
workflow:github_cli Using gh CLI via go-gh/v2 for command: gh [api repos/{owner}/{repo}/actions/runs/99999999999 ...] +2ms
workflow:github_cli GH_TOKEN not set, using GITHUB_TOKEN for gh CLI +42µs
✗ failed to fetch run metadata: workflow run 99999999999 not found. Please verify the run ID is correct and that you have access to the repository

The debug logger initialization messages (using the logger package with pkg:filename namespace format) are being captured from stderr and included verbatim in the MCP error message.

Root Cause

The MCP server appears to capture the binary's stderr output and include it in the error message. When debug logging is active (or when initialization logs are emitted unconditionally), these get bundled into the error response returned to the caller.

Environment

  • Repository: github/gh-aw
  • Run ID: 22648129225
  • Date: 2026-03-03
  • Testing via: Daily CLI Tools Exploratory Tester

Impact

  • Severity: Medium
  • Frequency: Always (reproducible with any invalid run ID)
  • Workaround: Scroll to the end of the error message to find the actual error

The issue degrades developer experience when troubleshooting audit failures, as the actual error is obscured by internal diagnostic output. It also exposes internal implementation details (module names, timing data) to end users.

Suggested Fix

Either:

  1. Ensure the MCP server only includes the final error message (not full stderr output) when propagating errors to callers, or
  2. Suppress debug initialization logs from stderr when the binary is not explicitly in debug mode (i.e., DEBUG env var not set)

Generated by Daily CLI Tools Exploratory Tester ·

  • expires on Mar 10, 2026, 11:55 PM UTC

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

When the audit tool is called with an invalid run ID and DEBUG=* is set
in the environment, the subprocess inherits the env and emits debug
initialization logs to stderr. These were being included verbatim in
the MCP error response as mainMsg.

Add extractLastConsoleMessage() helper that filters debug log lines
(e.g. "workflow:script_registry Creating... +151ns") and returns only
the last user-facing console message (lines starting with ✗, ✓, ℹ, etc.).

The full stderr is still preserved in errorData.stderr for debugging.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix debug initialization logs in MCP error response fix(mcp): filter debug log lines from audit tool error response Mar 4, 2026
@pelikhan pelikhan marked this pull request as ready for review March 4, 2026 05:21
Copilot AI review requested due to automatic review settings March 4, 2026 05:21
@pelikhan pelikhan merged commit 677910a into main Mar 4, 2026
100 checks passed
@pelikhan pelikhan deleted the copilot/fix-debug-log-in-error branch March 4, 2026 05:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Filters noisy debug initialization logs out of the MCP audit tool’s surfaced error message so callers see the intended user-facing console error, while still preserving full stderr in structured error data.

Changes:

  • Replaces strings.TrimSpace(stderr) with extractLastConsoleMessage(stderr) when constructing the MCP error message for the audit tool.
  • Adds extractLastConsoleMessage helper that prefers the last console-prefixed line (✗/✓/ℹ/⚠/etc.) and otherwise falls back to the last non-empty line.
  • Adds unit tests covering empty/whitespace stderr, debug-only output, mixed output, and multiple console messages.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/cli/mcp_tools_privileged.go Uses a new helper to extract a user-facing stderr line for MCP audit errors instead of returning full stderr as the message.
pkg/cli/mcp_tools_privileged_test.go Adds unit tests validating the stderr line extraction behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

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.

[cli-tools-test] audit: debug initialization logs leaked in MCP error response for invalid run IDs

3 participants