-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(serve): keep prompt-turn failure logs from degrading to [object Object] #10732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yiliang114
merged 8 commits into
QwenLM:main
from
yiliang114:fix/serve-turn-failure-log-detail
Sep 2, 2026
+126
−3
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c72be0f
fix(serve): keep prompt-turn failure logs from degrading to [object O…
yiliang114 9c79a6a
fix(web-shell): drop duplicated language binding in ChatEditor tests
yiliang114 7efa602
Merge branch 'main' into fix/serve-turn-failure-log-detail
yiliang114 a397b95
Merge remote-tracking branch 'origin/main' into codex/pr-10732-closeo…
yiliang114 69283bf
fix(serve): handle degenerate prompt failure objects
yiliang114 9b5213b
fix(serve): render non-serializable prompt failures with util.inspect
yiliang114 25e9c6e
Merge branch 'main' into fix/serve-turn-failure-log-detail
yiliang114 662105a
Merge branch 'main' into fix/serve-turn-failure-log-detail
yiliang114 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
packages/cli/src/serve/routes/session-turn-failure.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Qwen Team | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { describe, expect, it } from 'vitest'; | ||
| import { describePromptTurnFailure } from './session.js'; | ||
|
|
||
| describe('describePromptTurnFailure', () => { | ||
| it('keeps Error name and message', () => { | ||
| const err = new Error('agent channel closed mid-request'); | ||
| err.name = 'BridgeChannelClosedError'; | ||
| expect(describePromptTurnFailure(err)).toBe( | ||
| '[BridgeChannelClosedError] agent channel closed mid-request', | ||
| ); | ||
| }); | ||
|
|
||
| it('extracts data details from Error rejections carrying JSON-RPC data', () => { | ||
| const err = Object.assign(new Error('Internal error'), { | ||
| name: 'RequestError', | ||
| data: { details: 'session not found' }, | ||
| }); | ||
| expect(describePromptTurnFailure(err)).toBe( | ||
| '[RequestError] session not found', | ||
| ); | ||
| }); | ||
|
|
||
| it('keeps the Error name prefix over a code prefix', () => { | ||
| const err = Object.assign(new Error('write EPIPE'), { code: 'EPIPE' }); | ||
| expect(describePromptTurnFailure(err)).toBe('[Error] write EPIPE'); | ||
| }); | ||
|
|
||
| it('extracts message and code from a bare JSON-RPC error object', () => { | ||
| expect( | ||
| describePromptTurnFailure({ code: -32603, message: 'Internal error' }), | ||
| ).toBe('[code -32603] Internal error'); | ||
| }); | ||
|
|
||
| it('prefers JSON-RPC data details over the generic message', () => { | ||
| expect( | ||
| describePromptTurnFailure({ | ||
| code: -32603, | ||
| message: 'Internal error', | ||
| data: { details: 'model provider rejected the request' }, | ||
| }), | ||
| ).toBe('[code -32603] model provider rejected the request'); | ||
| }); | ||
|
|
||
| it('prefers nested provider error text shipped as parsed data', () => { | ||
| expect( | ||
| describePromptTurnFailure({ | ||
| code: -32603, | ||
| message: 'Internal error', | ||
| data: { error: { message: 'upstream 429 rate limited' } }, | ||
| }), | ||
| ).toBe('[code -32603] upstream 429 rate limited'); | ||
| }); | ||
|
|
||
| it('reads a plain object message property without a code', () => { | ||
| expect(describePromptTurnFailure({ message: 'something broke' })).toBe( | ||
| 'something broke', | ||
| ); | ||
| }); | ||
|
|
||
| it('never degrades structured rejections to [object Object]', () => { | ||
| const candidates: unknown[] = [ | ||
| { code: -32000, message: 'boom' }, | ||
| { code: 'EPIPE', message: 'write failed' }, | ||
| { data: 'provider closed the stream' }, | ||
| { message: 'partial' }, | ||
| { code: -32603 }, | ||
| {}, | ||
| { message: '' }, | ||
| ]; | ||
| for (const candidate of candidates) { | ||
| const rendered = describePromptTurnFailure(candidate); | ||
| expect(rendered).not.toBe(''); | ||
| expect(rendered).not.toContain('[object Object]'); | ||
| } | ||
| }); | ||
|
|
||
| it('renders circular rejections without degrading', () => { | ||
| const err: Record<string, unknown> = { code: -32603 }; | ||
| err['self'] = err; | ||
| const rendered = describePromptTurnFailure(err); | ||
| expect(rendered).toContain('[code -32603]'); | ||
| expect(rendered).not.toContain('[object Object]'); | ||
| }); | ||
|
|
||
| it('stringifies primitive rejections', () => { | ||
| expect(describePromptTurnFailure('socket hang up')).toBe('socket hang up'); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.