fix(logs): detect additional error payload fields
This commit is contained in:
parent
9d419626ef
commit
0e080abefb
2 changed files with 40 additions and 1 deletions
|
|
@ -425,6 +425,39 @@ Reply to this comment using MCP tool task_add_comment.
|
||||||
expect(result.items[0]?.preview).not.toContain('{"type"');
|
expect(result.items[0]?.preview).not.toContain('{"type"');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('marks structured isError payloads as errors and prefers stderr details', () => {
|
||||||
|
const result = extractMemberLogPreviewItems({
|
||||||
|
provider: 'opencode_runtime',
|
||||||
|
maxItems: 3,
|
||||||
|
textLimit: 160,
|
||||||
|
messages: [
|
||||||
|
message({
|
||||||
|
uuid: 'stderr-result',
|
||||||
|
type: 'user',
|
||||||
|
role: 'user',
|
||||||
|
timestamp: '2026-04-01T10:01:00.000Z',
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: 'tool_result',
|
||||||
|
tool_use_id: 'tool-stderr',
|
||||||
|
content: {
|
||||||
|
isError: true,
|
||||||
|
stderr: 'Permission denied while writing app/index.tsx',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.items[0]).toMatchObject({
|
||||||
|
kind: 'tool_result',
|
||||||
|
title: 'Tool error',
|
||||||
|
preview: 'Permission denied while writing app/index.tsx',
|
||||||
|
tone: 'error',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('formats orphan comment result payloads without guessing add vs read semantics', () => {
|
it('formats orphan comment result payloads without guessing add vs read semantics', () => {
|
||||||
const result = extractMemberLogPreviewItems({
|
const result = extractMemberLogPreviewItems({
|
||||||
provider: 'claude_transcript',
|
provider: 'claude_transcript',
|
||||||
|
|
|
||||||
|
|
@ -297,7 +297,12 @@ function unknownPayloadLooksLikeError(value: unknown): boolean {
|
||||||
if (type === 'error' || type?.endsWith('_error')) {
|
if (type === 'error' || type?.endsWith('_error')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (record.ok === false || record.success === false) {
|
if (
|
||||||
|
record.ok === false ||
|
||||||
|
record.success === false ||
|
||||||
|
record.isError === true ||
|
||||||
|
record.is_error === true
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -325,6 +330,7 @@ function payloadErrorMessage(payload: Record<string, unknown>): string | null {
|
||||||
const direct =
|
const direct =
|
||||||
stringField(payload, 'error') ??
|
stringField(payload, 'error') ??
|
||||||
stringField(payload, 'errorMessage') ??
|
stringField(payload, 'errorMessage') ??
|
||||||
|
stringField(payload, 'stderr') ??
|
||||||
stringField(payload, 'message');
|
stringField(payload, 'message');
|
||||||
if (direct) {
|
if (direct) {
|
||||||
return direct;
|
return direct;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue