From ef2cd7d996b538d8497999bb502fbf62ffceb4d7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 May 2026 16:10:08 +0000 Subject: [PATCH 1/4] Initial plan From ffecf7d0923d233fba9930ee2ff00ffb5212bbae Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 May 2026 16:27:17 +0000 Subject: [PATCH 2/4] Initial plan Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/aw/actions-lock.json | 5 +++ .../developer-docs-consolidator.lock.yml | 34 +++++++++---------- .github/workflows/release.lock.yml | 8 ++--- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.github/aw/actions-lock.json b/.github/aw/actions-lock.json index 828732d7e61..15645cd1268 100644 --- a/.github/aw/actions-lock.json +++ b/.github/aw/actions-lock.json @@ -148,6 +148,11 @@ "version": "v6.0.0", "sha": "030e881283bb7a6894de51c315a6bfe6a94e05cf" }, + "docker/setup-buildx-action@v4": { + "repo": "docker/setup-buildx-action", + "version": "v4", + "sha": "d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5" + }, "docker/setup-buildx-action@v4.0.0": { "repo": "docker/setup-buildx-action", "version": "v4.0.0", diff --git a/.github/workflows/developer-docs-consolidator.lock.yml b/.github/workflows/developer-docs-consolidator.lock.yml index e4b1b5fc59c..ac1053ae173 100644 --- a/.github/workflows/developer-docs-consolidator.lock.yml +++ b/.github/workflows/developer-docs-consolidator.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"a4d6c0e0eea19e818c539ce209737406af302285f0c38fc66e12de384ebfd5a7","strict":true,"agent_id":"claude"} +# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"2f551d0f93c0fe290cddec96b13eb87b6c71b91fc363a1b51d2ceb35a1de4368","strict":true,"agent_id":"claude"} # gh-aw-manifest: {"version":1,"secrets":["ANTHROPIC_API_KEY","GH_AW_CI_TRIGGER_TOKEN","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GH_AW_OTEL_GRAFANA_AUTHORIZATION","GH_AW_OTEL_GRAFANA_ENDPOINT","GH_AW_OTEL_SENTRY_AUTHORIZATION","GH_AW_OTEL_SENTRY_ENDPOINT","GITHUB_TOKEN"],"actions":[{"repo":"actions/cache/restore","sha":"27d5ce7f107fe9357f9df03efb73ab90386fccae","version":"v5.0.5"},{"repo":"actions/cache/save","sha":"27d5ce7f107fe9357f9df03efb73ab90386fccae","version":"v5.0.5"},{"repo":"actions/checkout","sha":"de0fac2e4500dabe0009e67214ff5f5447ce83dd","version":"v6.0.2"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e","version":"v6.4.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.25.51"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.51"},{"image":"ghcr.io/github/gh-aw-firewall/cli-proxy:0.25.51"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.25.51"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.3.17"},{"image":"ghcr.io/github/github-mcp-server:v1.0.4"},{"image":"ghcr.io/github/serena-mcp-server:latest","digest":"sha256:bf343399e3725c45528f531a230f3a04521d4cdef29f9a5af6282ff0d3c393c5","pinned_image":"ghcr.io/github/serena-mcp-server:latest@sha256:bf343399e3725c45528f531a230f3a04521d4cdef29f9a5af6282ff0d3c393c5"},{"image":"node:lts-alpine","digest":"sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f","pinned_image":"node:lts-alpine@sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f"}]} # ___ _ _ # / _ \ | | (_) @@ -67,8 +67,8 @@ name: "Developer Documentation Consolidator" on: schedule: - - cron: "19 13 * * *" - # Friendly format: daily (scattered) + - cron: "19 13 * * 6" + # Friendly format: weekly (scattered) workflow_dispatch: inputs: aw_context: @@ -210,25 +210,25 @@ jobs: run: | bash "${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh" { - cat << 'GH_AW_PROMPT_11ae19bf7a59d533_EOF' + cat << 'GH_AW_PROMPT_d5fa5c99cbb130c2_EOF' - GH_AW_PROMPT_11ae19bf7a59d533_EOF + GH_AW_PROMPT_d5fa5c99cbb130c2_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/xpia.md" cat "${RUNNER_TEMP}/gh-aw/prompts/temp_folder_prompt.md" cat "${RUNNER_TEMP}/gh-aw/prompts/markdown.md" cat "${RUNNER_TEMP}/gh-aw/prompts/cache_memory_prompt.md" cat "${RUNNER_TEMP}/gh-aw/prompts/repo_memory_prompt.md" cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_prompt.md" - cat << 'GH_AW_PROMPT_11ae19bf7a59d533_EOF' + cat << 'GH_AW_PROMPT_d5fa5c99cbb130c2_EOF' Tools: create_discussion, create_pull_request, missing_tool, missing_data, noop - GH_AW_PROMPT_11ae19bf7a59d533_EOF + GH_AW_PROMPT_d5fa5c99cbb130c2_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_create_pull_request.md" - cat << 'GH_AW_PROMPT_11ae19bf7a59d533_EOF' + cat << 'GH_AW_PROMPT_d5fa5c99cbb130c2_EOF' - GH_AW_PROMPT_11ae19bf7a59d533_EOF + GH_AW_PROMPT_d5fa5c99cbb130c2_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/mcp_cli_tools_prompt.md" - cat << 'GH_AW_PROMPT_11ae19bf7a59d533_EOF' + cat << 'GH_AW_PROMPT_d5fa5c99cbb130c2_EOF' The following GitHub context information is available for this workflow: {{#if github.actor}} @@ -257,9 +257,9 @@ jobs: {{/if}} - GH_AW_PROMPT_11ae19bf7a59d533_EOF + GH_AW_PROMPT_d5fa5c99cbb130c2_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/cli_proxy_with_safeoutputs_prompt.md" - cat << 'GH_AW_PROMPT_11ae19bf7a59d533_EOF' + cat << 'GH_AW_PROMPT_d5fa5c99cbb130c2_EOF' ## Serena Code Analysis @@ -297,7 +297,7 @@ jobs: {{#runtime-import .github/workflows/shared/reporting.md}} {{#runtime-import .github/workflows/shared/noop-reminder.md}} {{#runtime-import .github/workflows/developer-docs-consolidator.md}} - GH_AW_PROMPT_11ae19bf7a59d533_EOF + GH_AW_PROMPT_d5fa5c99cbb130c2_EOF } > "$GH_AW_PROMPT" - name: Interpolate variables and render templates uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 @@ -557,9 +557,9 @@ jobs: mkdir -p "${RUNNER_TEMP}/gh-aw/safeoutputs" mkdir -p /tmp/gh-aw/safeoutputs mkdir -p /tmp/gh-aw/mcp-logs/safeoutputs - cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << 'GH_AW_SAFE_OUTPUTS_CONFIG_a353b88931d048e1_EOF' + cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << 'GH_AW_SAFE_OUTPUTS_CONFIG_0f4abc9d17592de4_EOF' {"create_discussion":{"category":"audits","close_older_discussions":true,"expires":72,"fallback_to_issue":true,"max":1,"title_prefix":"[developer-docs] "},"create_pull_request":{"draft":false,"expires":48,"labels":["documentation","automation"],"max":1,"max_patch_files":100,"max_patch_size":1024,"protect_top_level_dot_folders":true,"protected_files":["package.json","bun.lockb","bunfig.toml","deno.json","deno.jsonc","deno.lock","global.json","NuGet.Config","Directory.Packages.props","mix.exs","mix.lock","go.mod","go.sum","stack.yaml","stack.yaml.lock","pom.xml","build.gradle","build.gradle.kts","settings.gradle","settings.gradle.kts","gradle.properties","package-lock.json","yarn.lock","pnpm-lock.yaml","npm-shrinkwrap.json","requirements.txt","Pipfile","Pipfile.lock","pyproject.toml","setup.py","setup.cfg","Gemfile","Gemfile.lock","uv.lock","CODEOWNERS","DESIGN.md","README.md","CONTRIBUTING.md","CHANGELOG.md","SECURITY.md","CODE_OF_CONDUCT.md","CLAUDE.md","AGENTS.md"],"protected_files_policy":"request_review","title_prefix":"[docs] "},"create_report_incomplete_issue":{},"missing_data":{},"missing_tool":{},"noop":{"max":1,"report-as-issue":"true"},"push_repo_memory":{"memories":[{"dir":"/tmp/gh-aw/repo-memory/default","id":"default","max_file_count":100,"max_file_size":102400,"max_patch_size":10240}]},"report_incomplete":{}} - GH_AW_SAFE_OUTPUTS_CONFIG_a353b88931d048e1_EOF + GH_AW_SAFE_OUTPUTS_CONFIG_0f4abc9d17592de4_EOF - name: Generate Safe Outputs Tools env: GH_AW_TOOLS_META_JSON: | @@ -798,7 +798,7 @@ jobs: export MCP_GATEWAY_DOCKER_COMMAND='docker run -i --rm --network host --add-host host.docker.internal:127.0.0.1 --user '"${MCP_GATEWAY_UID}"':'"${MCP_GATEWAY_GID}"' --group-add '"${DOCKER_SOCK_GID}"' -v '"${DOCKER_SOCK_PATH}"':/var/run/docker.sock -e MCP_GATEWAY_PORT -e MCP_GATEWAY_DOMAIN -e MCP_GATEWAY_API_KEY -e MCP_GATEWAY_PAYLOAD_DIR -e MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD -e DOCKER_HOST=unix:///var/run/docker.sock -e DEBUG -e MCP_GATEWAY_LOG_DIR -e GH_AW_MCP_LOG_DIR -e GH_AW_SAFE_OUTPUTS -e GH_AW_SAFE_OUTPUTS_CONFIG_PATH -e GH_AW_SAFE_OUTPUTS_TOOLS_PATH -e GH_AW_ASSETS_BRANCH -e GH_AW_ASSETS_MAX_SIZE_KB -e GH_AW_ASSETS_ALLOWED_EXTS -e DEFAULT_BRANCH -e GITHUB_MCP_SERVER_TOKEN -e GITHUB_MCP_GUARD_MIN_INTEGRITY -e GITHUB_MCP_GUARD_REPOS -e GITHUB_REPOSITORY -e GITHUB_SERVER_URL -e GITHUB_SHA -e GITHUB_WORKSPACE -e GITHUB_TOKEN -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RUN_ATTEMPT -e GITHUB_JOB -e GITHUB_ACTION -e GITHUB_EVENT_NAME -e GITHUB_EVENT_PATH -e GITHUB_ACTOR -e GITHUB_ACTOR_ID -e GITHUB_TRIGGERING_ACTOR -e GITHUB_WORKFLOW -e GITHUB_WORKFLOW_REF -e GITHUB_WORKFLOW_SHA -e GITHUB_REF -e GITHUB_REF_NAME -e GITHUB_REF_TYPE -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GH_AW_SAFE_OUTPUTS_PORT -e GH_AW_SAFE_OUTPUTS_API_KEY -e GITHUB_AW_OTEL_TRACE_ID -e GITHUB_AW_OTEL_PARENT_SPAN_ID -e OTEL_EXPORTER_OTLP_HEADERS -v /tmp/gh-aw/mcp-payloads:/tmp/gh-aw/mcp-payloads:rw -v /opt:/opt:ro -v /tmp:/tmp:rw -v '"${GITHUB_WORKSPACE}"':'"${GITHUB_WORKSPACE}"':rw ghcr.io/github/gh-aw-mcpg:v0.3.17' GH_AW_NODE=$(which node 2>/dev/null || command -v node 2>/dev/null || echo node) - cat << GH_AW_MCP_CONFIG_2325e44fc17fd82e_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs" + cat << GH_AW_MCP_CONFIG_c0233e142ad8ebdb_EOF | "$GH_AW_NODE" "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.cjs" { "mcpServers": { "safeoutputs": { @@ -854,7 +854,7 @@ jobs: } } } - GH_AW_MCP_CONFIG_2325e44fc17fd82e_EOF + GH_AW_MCP_CONFIG_c0233e142ad8ebdb_EOF - name: Mount MCP servers as CLIs id: mount-mcp-clis continue-on-error: true diff --git a/.github/workflows/release.lock.yml b/.github/workflows/release.lock.yml index 0a1401ad760..2a34e61dd64 100644 --- a/.github/workflows/release.lock.yml +++ b/.github/workflows/release.lock.yml @@ -1,5 +1,5 @@ # gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"6a6bd39e2339b2b176862a0fceb3dc70c2440fe79b8689f4e476134a57bed33a","strict":true,"agent_id":"copilot"} -# gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GH_AW_OTEL_GRAFANA_AUTHORIZATION","GH_AW_OTEL_GRAFANA_ENDPOINT","GH_AW_OTEL_SENTRY_AUTHORIZATION","GH_AW_OTEL_SENTRY_ENDPOINT","GITHUB_TOKEN"],"actions":[{"repo":"actions/checkout","sha":"de0fac2e4500dabe0009e67214ff5f5447ce83dd","version":"v6.0.2"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-go","sha":"4a3601121dd01d1626a1e23e37211e3254c1c06c","version":"v6.4.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"},{"repo":"anchore/sbom-action","sha":"e22c389904149dbc22b58101806040fa8d37a610","version":"v0.24.0"},{"repo":"docker/build-push-action","sha":"bcafcacb16a39f128d818304e6c9c0c18556b85f","version":"v7.1.0"},{"repo":"docker/login-action","sha":"4907a6ddec9925e35a0a9e82d7399ccc52663121","version":"v4.1.0"},{"repo":"docker/metadata-action","sha":"80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9","version":"v6"},{"repo":"docker/setup-buildx-action","sha":"4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd","version":"v4.0.0 (source v4)"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.25.51"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.51"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.25.51"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.3.17"},{"image":"ghcr.io/github/github-mcp-server:v1.0.4"},{"image":"node:lts-alpine","digest":"sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f","pinned_image":"node:lts-alpine@sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f"}]} +# gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GH_AW_OTEL_GRAFANA_AUTHORIZATION","GH_AW_OTEL_GRAFANA_ENDPOINT","GH_AW_OTEL_SENTRY_AUTHORIZATION","GH_AW_OTEL_SENTRY_ENDPOINT","GITHUB_TOKEN"],"actions":[{"repo":"actions/checkout","sha":"de0fac2e4500dabe0009e67214ff5f5447ce83dd","version":"v6.0.2"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-go","sha":"4a3601121dd01d1626a1e23e37211e3254c1c06c","version":"v6.4.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"},{"repo":"anchore/sbom-action","sha":"e22c389904149dbc22b58101806040fa8d37a610","version":"v0.24.0"},{"repo":"docker/build-push-action","sha":"bcafcacb16a39f128d818304e6c9c0c18556b85f","version":"v7.1.0"},{"repo":"docker/login-action","sha":"4907a6ddec9925e35a0a9e82d7399ccc52663121","version":"v4.1.0"},{"repo":"docker/metadata-action","sha":"80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9","version":"v6"},{"repo":"docker/setup-buildx-action","sha":"d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5","version":"v4"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.25.51"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.51"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.25.51"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.3.17"},{"image":"ghcr.io/github/github-mcp-server:v1.0.4"},{"image":"node:lts-alpine","digest":"sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f","pinned_image":"node:lts-alpine@sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f"}]} # ___ _ _ # / _ \ | | (_) # | |_| | __ _ ___ _ __ | |_ _ ___ @@ -50,7 +50,7 @@ # - docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 # - docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 # - docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6 -# - docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 (source v4) +# - docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4 # # Container images used: # - ghcr.io/github/gh-aw-firewall/agent:0.25.51 @@ -1372,7 +1372,7 @@ jobs: env: RELEASE_TAG: ${{ needs.config.outputs.release_tag }} - name: Setup Docker Buildx (pre-validation) - uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 (source v4) + uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4 - name: Build Docker image (validation only) uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 with: @@ -1532,7 +1532,7 @@ jobs: sbom.cdx.json retention-days: 90 - name: Setup Docker Buildx - uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 (source v4) + uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4 - name: Log in to GitHub Container Registry uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 with: From 199879347ac380506951f3a7c168e01d793ade17 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 May 2026 16:29:18 +0000 Subject: [PATCH 3/4] fix: infer MCP tool-call status from level/error when status field is absent Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/gateway_logs_mcp.go | 14 ++++- pkg/cli/gateway_logs_parsing.go | 5 +- pkg/cli/gateway_logs_test.go | 90 +++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+), 3 deletions(-) diff --git a/pkg/cli/gateway_logs_mcp.go b/pkg/cli/gateway_logs_mcp.go index 9568c222051..82979331b79 100644 --- a/pkg/cli/gateway_logs_mcp.go +++ b/pkg/cli/gateway_logs_mcp.go @@ -135,6 +135,18 @@ func extractToolCallsFromGatewayLog(gatewayLogPath string, mcpData *MCPToolUsage continue } + // Derive status from available fields when not explicitly set. + // Post-OTel-collector migrations may omit the "status" string field, + // relying instead on "error" or "level" to signal failures. + status := entry.Status + if status == "" { + if entry.Error != "" || entry.Level == "error" { + status = "error" + } else { + status = "success" + } + } + // Create individual tool call record toolCall := MCPToolCall{ Timestamp: entry.Timestamp, @@ -143,7 +155,7 @@ func extractToolCallsFromGatewayLog(gatewayLogPath string, mcpData *MCPToolUsage Method: entry.Method, InputSize: entry.InputSize, OutputSize: entry.OutputSize, - Status: entry.Status, + Status: status, Error: entry.Error, } diff --git a/pkg/cli/gateway_logs_parsing.go b/pkg/cli/gateway_logs_parsing.go index a95ffa824b9..f96b1e7b311 100644 --- a/pkg/cli/gateway_logs_parsing.go +++ b/pkg/cli/gateway_logs_parsing.go @@ -161,8 +161,9 @@ func processGatewayLogEntry(entry *GatewayLogEntry, metrics *GatewayMetrics, ver return } - // Track errors - if entry.Status == "error" || entry.Error != "" { + // Track errors. Include entries where level is "error" to handle gateway log formats + // that omit the "status" field post-OTel-collector migration. + if entry.Status == "error" || entry.Error != "" || entry.Level == "error" { metrics.TotalErrors++ if entry.ServerName != "" { server := getOrCreateServer(metrics, entry.ServerName) diff --git a/pkg/cli/gateway_logs_test.go b/pkg/cli/gateway_logs_test.go index fd059219481..7eeb4bf55ee 100644 --- a/pkg/cli/gateway_logs_test.go +++ b/pkg/cli/gateway_logs_test.go @@ -1007,3 +1007,93 @@ func TestExtractMCPToolUsageDataWithGuardPolicy(t *testing.T) { require.Len(t, mcpData.GuardPolicySummary.Events, 1) assert.Equal(t, "pull_request_read", mcpData.GuardPolicySummary.Events[0].ToolName) } + +// TestExtractToolCallsStatusInference verifies that extractToolCallsFromGatewayLog correctly +// infers the per-call status when the gateway.jsonl entry omits the "status" field. +// Post-OTel-collector migrations may drop the explicit "status" key; the parser must +// fall back to the "error"/"level" fields to produce "success" or "error" rather than +// leaving Status blank (which downstream agents render as "unknown"). +func TestExtractToolCallsStatusInference(t *testing.T) { + tests := []struct { + name string + logLine string + wantStatus string + wantErrField string + }{ + { + name: "explicit status success", + logLine: `{"timestamp":"2024-01-12T10:00:00Z","level":"info","event":"tool_call","server_name":"github","tool_name":"list_issues","duration":100,"status":"success"}`, + wantStatus: "success", + }, + { + name: "explicit status error with error field", + logLine: `{"timestamp":"2024-01-12T10:00:01Z","level":"error","event":"tool_call","server_name":"github","tool_name":"list_issues","duration":50,"status":"error","error":"rate limit"}`, + wantStatus: "error", + wantErrField: "rate limit", + }, + { + name: "no status field, level info — infer success", + logLine: `{"timestamp":"2024-01-12T10:00:02Z","level":"info","event":"tool_call","server_name":"github","tool_name":"list_issues","duration":120}`, + wantStatus: "success", + }, + { + name: "no status field, level error — infer error", + logLine: `{"timestamp":"2024-01-12T10:00:03Z","level":"error","event":"tool_call","server_name":"github","tool_name":"list_issues","duration":30}`, + wantStatus: "error", + wantErrField: "", + }, + { + name: "no status field, non-empty error field — infer error", + logLine: `{"timestamp":"2024-01-12T10:00:04Z","level":"info","event":"tool_call","server_name":"github","tool_name":"list_issues","duration":40,"error":"connection reset"}`, + wantStatus: "error", + wantErrField: "connection reset", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tmpDir := t.TempDir() + gatewayLogPath := filepath.Join(tmpDir, "gateway.jsonl") + require.NoError(t, os.WriteFile(gatewayLogPath, []byte(tt.logLine+"\n"), 0644)) + + mcpData := &MCPToolUsageData{ToolCalls: []MCPToolCall{}} + require.NoError(t, extractToolCallsFromGatewayLog(gatewayLogPath, mcpData)) + require.Len(t, mcpData.ToolCalls, 1, "should have exactly one tool call record") + + tc := mcpData.ToolCalls[0] + assert.Equal(t, tt.wantStatus, tc.Status, "tool call status mismatch") + assert.Equal(t, tt.wantErrField, tc.Error, "tool call error field mismatch") + }) + } +} + +// TestProcessGatewayLogEntryLevelErrorCounting verifies that processGatewayLogEntry +// counts a tool-call entry as an error when "level":"error" is set, even if the +// "status" and "error" fields are absent (post-OTel format drift). +func TestProcessGatewayLogEntryLevelErrorCounting(t *testing.T) { + metrics := &GatewayMetrics{ + Servers: make(map[string]*GatewayServerMetrics), + } + + // Simulate a gateway log entry that uses level:"error" without an explicit status field. + entry := &GatewayLogEntry{ + Timestamp: "2024-01-12T10:00:00Z", + Level: "error", + Event: "tool_call", + ServerName: "github", + ToolName: "list_issues", + Duration: 50, + } + + processGatewayLogEntry(entry, metrics, false) + + assert.Equal(t, 1, metrics.TotalRequests, "should count as a request") + assert.Equal(t, 1, metrics.TotalErrors, "level:error should increment TotalErrors") + + server := metrics.Servers["github"] + require.NotNil(t, server) + assert.Equal(t, 1, server.ErrorCount, "server error count should be 1") + tool := server.Tools["list_issues"] + require.NotNil(t, tool) + assert.Equal(t, 1, tool.ErrorCount, "tool error count should be 1") +} From 24a77375d57180eb44b21eec6b1632ee6197dce1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 May 2026 16:33:13 +0000 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20address=20code=20review=20feedback?= =?UTF-8?q?=20=E2=80=94=20use=200600=20perms=20and=20require.Equal=20for?= =?UTF-8?q?=20status=20assert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/gateway_logs_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/cli/gateway_logs_test.go b/pkg/cli/gateway_logs_test.go index 7eeb4bf55ee..9695f41809c 100644 --- a/pkg/cli/gateway_logs_test.go +++ b/pkg/cli/gateway_logs_test.go @@ -1054,14 +1054,14 @@ func TestExtractToolCallsStatusInference(t *testing.T) { t.Run(tt.name, func(t *testing.T) { tmpDir := t.TempDir() gatewayLogPath := filepath.Join(tmpDir, "gateway.jsonl") - require.NoError(t, os.WriteFile(gatewayLogPath, []byte(tt.logLine+"\n"), 0644)) + require.NoError(t, os.WriteFile(gatewayLogPath, []byte(tt.logLine+"\n"), 0600)) mcpData := &MCPToolUsageData{ToolCalls: []MCPToolCall{}} require.NoError(t, extractToolCallsFromGatewayLog(gatewayLogPath, mcpData)) require.Len(t, mcpData.ToolCalls, 1, "should have exactly one tool call record") tc := mcpData.ToolCalls[0] - assert.Equal(t, tt.wantStatus, tc.Status, "tool call status mismatch") + require.Equal(t, tt.wantStatus, tc.Status, "tool call status mismatch") assert.Equal(t, tt.wantErrField, tc.Error, "tool call error field mismatch") }) }