mirror of
https://github.com/stablyai/orca.git
synced 2026-10-07 00:02:29 +00:00
Preserve OpenCode named errors without a data message
This commit is contained in:
@@ -55,13 +55,30 @@ describe('OpenCode generation event output', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it.each(['{broken', '{"title":"not an event"}', 'null'])(
|
||||
'rejects malformed events %s',
|
||||
(output) => {
|
||||
expect(parseOpenCodeGenerationOutput(output)).toEqual({
|
||||
ok: false,
|
||||
error: 'OpenCode returned invalid JSON events.'
|
||||
})
|
||||
it.each([
|
||||
{ error: { name: 'MessageOutputLengthError', data: {} }, expected: 'MessageOutputLengthError' },
|
||||
{
|
||||
error: { name: 'ProviderError', data: { retryable: false } },
|
||||
expected: 'ProviderError'
|
||||
},
|
||||
{
|
||||
error: { name: 'ProviderError', message: 'Provider rejected the request', data: {} },
|
||||
expected: 'Provider rejected the request'
|
||||
}
|
||||
)
|
||||
])('reports named errors without a data message', ({ error, expected }) => {
|
||||
const output = `${frame('text', 'partial')}\n${JSON.stringify({ type: 'error', error })}`
|
||||
expect(parseOpenCodeGenerationOutput(output)).toEqual({ ok: false, error: expected })
|
||||
})
|
||||
|
||||
it.each([
|
||||
'{broken',
|
||||
'{"title":"not an event"}',
|
||||
'null',
|
||||
JSON.stringify({ type: 'error', error: { name: 'ProviderError', data: { message: 42 } } })
|
||||
])('rejects malformed events %s', (output) => {
|
||||
expect(parseOpenCodeGenerationOutput(output)).toEqual({
|
||||
ok: false,
|
||||
error: 'OpenCode returned invalid JSON events.'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ const eventSchema = z.object({
|
||||
.object({
|
||||
name: z.string().optional(),
|
||||
message: z.string().optional(),
|
||||
data: z.object({ message: z.string() }).optional()
|
||||
data: z.object({ message: z.string().optional() }).optional()
|
||||
})
|
||||
.optional()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user