Skip to content

fix(mcp): attach mcp_tool/error_code to the remote sink's exception capture - #10236

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-10037
Jul 31, 2026
Merged

fix(mcp): attach mcp_tool/error_code to the remote sink's exception capture#10236
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-10037

Conversation

@bitfathers94

Copy link
Copy Markdown
Contributor

fix(mcp): attach mcp_tool/error_code to the remote sink's exception capture

The remote MCP telemetry sink's captureException call named these two
grouping properties in a comment but never actually sent them, so a
PostHog exception breakdown by tool/cause silently dropped the surface
with the most traffic while the stdio and miner sinks kept reporting.
Extend capturePostHogWorkerError with an optional, scrubbed extra
properties argument and pass mcp_tool/error_code through it, matching
the other two sinks property-for-property. The HTTP middleware path
keeps its existing request_path/request_method shape unchanged.

Closes #10037

…apture

The remote MCP telemetry sink's captureException call named these two
grouping properties in a comment but never actually sent them, so a
PostHog exception breakdown by tool/cause silently dropped the surface
with the most traffic while the stdio and miner sinks kept reporting.
Extend capturePostHogWorkerError with an optional, scrubbed extra
properties argument and pass mcp_tool/error_code through it, matching
the other two sinks property-for-property. The HTTP middleware path
keeps its existing request_path/request_method shape unchanged.
@bitfathers94
bitfathers94 requested a review from JSONbored as a code owner July 31, 2026 13:39
@loopover-orb

loopover-orb Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-31 13:47:35 UTC

4 files · 1 AI reviewer · no blockers · readiness 95/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
Fixes a real bug: capturePostHogWorkerError previously ignored the mcp_tool/error_code properties the MCP dispatch sink intended to attach, so the remote sink's PostHog exception breakdown couldn't group by tool/cause the way stdio/miner sinks could. The fix adds a properly scrubbed optional extraProperties parameter, merges it after the fixed properties (so mcp_tool/error_code can't clobber environment/request_path/request_method), and leaves the HTTP middleware path untouched by passing no fourth argument. Tests verify the merge, the scrubbing of secret-shaped extra values, and that the HTTP path still excludes mcp_tool — solid, targeted coverage of both new branches.

Nits — 4 non-blocking
  • worker-posthog.ts:112-114 spreads scrubbedExtra after the fixed properties, so a caller-supplied extraProperties could in principle override request_path/request_method/environment if key names ever collided — worth a comment noting this is intentional/relied-upon ordering rather than incidental.
  • dispatch-telemetry-sink.ts:99-104 still passes redundant `path`/`method` fields (mcp.tool/${tool}, errorCode) into the fixed WorkerErrorRequestContext alongside the new extraProperties, effectively duplicating mcp_tool/error_code information in two different property names (request_path/request_method vs mcp_tool/error_code) — confirm that's the intended dashboard shape rather than leftover duplication from before the fix.
  • Consider a short inline comment at the merge site in worker-posthog.ts confirming extraProperties intentionally cannot override the fixed keys, to prevent a future edit from reordering the spread.
  • If the request_path/request_method duplication in dispatch-telemetry-sink.ts is intentional (e.g., for backward dashboard compatibility), note that reasoning in the code comment for future readers.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #10037
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ⚠️ 20/25 Preflight is ready, but the PR body does not name the validation run.
Contributor workload ✅ 10/10 Author activity: 140 registered-repo PR(s), 99 merged, 3 issue(s).
Contributor context ✅ Confirmed Gittensor contributor bitfathers94; Gittensor profile; 140 PR(s), 3 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff extends capturePostHogWorkerError with a scrubbed optional extraProperties argument, passes {mcp_tool, error_code} from the dispatch sink matching the stdio/miner property names and defaulting to "unknown_error", and adds tests covering the tool/errorCode capture, the default-code arm, and that the HTTP middleware's request_path/request_method output is unaffected and lacks mcp_tool.

Review context
  • Author: bitfathers94
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: TypeScript
  • Official Gittensor activity: 140 PR(s), 3 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Add validation command/output.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 31, 2026
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.50%. Comparing base (e055c59) to head (7782add).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10236      +/-   ##
==========================================
+ Coverage   80.47%   80.50%   +0.02%     
==========================================
  Files         282      284       +2     
  Lines       58856    58924      +68     
  Branches     6978     7002      +24     
==========================================
+ Hits        47366    47434      +68     
  Misses      11199    11199              
  Partials      291      291              
Flag Coverage Δ
backend 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/api/worker-posthog.ts 100.00% <100.00%> (ø)
src/mcp/dispatch-telemetry-sink.ts 100.00% <100.00%> (ø)

@loopover-orb loopover-orb Bot 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.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit e664c35 into JSONbored:main Jul 31, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcp(telemetry): capture the remote server's tool exceptions under mcp_tool/error_code like the other two sinks

1 participant