Skip to content

Include error code and message in the 'Sending response' trace log - #1854

Merged
Dirk Bäumer (dbaeumer) merged 2 commits into
microsoft:mainfrom
pujitha24:auto/issue-1604
Sep 22, 2026
Merged

Dirk Bäumer (dbaeumer) merged 2 commits into
microsoft:mainfrom
pujitha24:auto/issue-1604

Conversation

@pujitha24

Copy link
Copy Markdown
Contributor

Motivation:
When a server sends back a JSON-RPC error response, the
'Sending response' trace line only surfaced error.data (when
present) but silently dropped error.code and error.message. A user
debugging a malformed request spent significant time investigating
because the trace output gave no indication that an error had even
occurred, even though the underlying response clearly carried a
-32602 error with a descriptive message.

Approach:
traceReceivedResponse (the client-side counterpart in the same file)
already appends "Request failed: ()." to its main
log line when message.error is set. Apply the identical pattern to
traceSendingResponse so the server-side trace line carries the same
information. This is a pure logging/string-formatting change with no
behavioral or API impact.

Validation:

  • npx tsc -b ./jsonrpc/tsconfig.json and npx tsc -b tsconfig.json
    (full monorepo) both compile cleanly.
  • npm run lint (eslint) in jsonrpc/ passes with no new warnings.
  • Added a test, "Trace includes error code and message when sending
    an error response", to jsonrpc/src/node/test/connection.test.ts.
    Ran npm run test:node in jsonrpc/: 68 passing, including the new
    test. Verified the test fails (times out, since the assertion runs
    inside a rejection-handler .then() callback, consistent with this
    file's existing test style) against the pre-fix code and passes
    against the fix.
  • Did not run the jsonrpc browser test suite (npm run test:browser)
    in this environment: it requires downloading a Playwright Chrome
    binary, which failed here due to local disk space constraints. The
    browser tests exercise the same shared
    jsonrpc/src/common/connection.ts trace code path, so this is a
    disclosed gap rather than a skipped check.

Report: #1604
Signed-off-by: Pujitha Paladugu 10557236+pujitha24@users.noreply.github.com
Assisted-by: claude-sonnet-5 (via Claude Code)

Fixes #1604

Motivation:
When a server sends back a JSON-RPC error response, the
'Sending response' trace line only surfaced error.data (when
present) but silently dropped error.code and error.message. A user
debugging a malformed request spent significant time investigating
because the trace output gave no indication that an error had even
occurred, even though the underlying response clearly carried a
-32602 error with a descriptive message.

Approach:
traceReceivedResponse (the client-side counterpart in the same file)
already appends "Request failed: <message> (<code>)." to its main
log line when message.error is set. Apply the identical pattern to
traceSendingResponse so the server-side trace line carries the same
information. This is a pure logging/string-formatting change with no
behavioral or API impact.

Validation:
- `npx tsc -b ./jsonrpc/tsconfig.json` and `npx tsc -b tsconfig.json`
  (full monorepo) both compile cleanly.
- `npm run lint` (eslint) in jsonrpc/ passes with no new warnings.
- Added a test, "Trace includes error code and message when sending
  an error response", to jsonrpc/src/node/test/connection.test.ts.
  Ran `npm run test:node` in jsonrpc/: 68 passing, including the new
  test. Verified the test fails (times out, since the assertion runs
  inside a rejection-handler `.then()` callback, consistent with this
  file's existing test style) against the pre-fix code and passes
  against the fix.
- Did not run the jsonrpc browser test suite (npm run test:browser)
  in this environment: it requires downloading a Playwright Chrome
  binary, which failed here due to local disk space constraints. The
  browser tests exercise the same shared
  jsonrpc/src/common/connection.ts trace code path, so this is a
  disclosed gap rather than a skipped check.

Report: microsoft#1604
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Assisted-by: claude-sonnet-5 (via Claude Code)
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused logging change is tested, with only minor punctuation cleanup outstanding.

Pull request overview

Adds JSON-RPC error details to server-side response traces for easier debugging.

Changes:

  • Logs error messages and codes when sending failed responses.
  • Adds regression coverage for error-response tracing.
File summaries
File Description
jsonrpc/src/node/test/connection.test.ts Tests error details in response traces.
jsonrpc/src/common/connection.ts Appends error messages and codes to traces.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread jsonrpc/src/common/connection.ts Outdated
Matches the existing traceReceivedResponse format so the trace line
reads as a proper sentence boundary, per Copilot review feedback.

Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
@pujitha24

Copy link
Copy Markdown
Contributor Author

Good catch, added the missing period so it now reads ...ms.${error}, matching traceReceivedResponse. Ran the jsonrpc node test suite again (68 passing, including the new trace test) to confirm nothing broke.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused change matches existing trace behavior and includes appropriate regression coverage.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@dbaeumer

Copy link
Copy Markdown
Member

/AzurePipelines run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@pujitha24

Copy link
Copy Markdown
Contributor Author

This is approved with green CI and no outstanding comments as far as I can tell — ready whenever you have a moment. Happy to rebase first if you'd like it freshened.

@dbaeumer
Dirk Bäumer (dbaeumer) merged commit 35409e7 into microsoft:main Sep 22, 2026
6 checks passed
@dbaeumer Dirk Bäumer (dbaeumer) added this to the 3.18.4 milestone Sep 23, 2026
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.

5 participants