refactor: use Zod validation for executionError getter

- Export zExecutionErrorWsMessage schema from apiSchema
- Use safeParse instead of type casts in TaskItemImpl.executionError
- Add logging on validation failure for debugging
- Keep errorMessage extraction in useJobErrorReporting via the getter

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Richard Yu
2026-01-12 18:46:26 -08:00
parent 400249cb08
commit 7ef92b0411
2 changed files with 3 additions and 59 deletions

View File

@@ -233,56 +233,8 @@ describe('TaskItemImpl', () => {
})
})
describe('error extraction getters', () => {
it('errorMessage returns undefined when no execution_error message', () => {
const taskItem = new TaskItemImpl(
'History',
[0, 'prompt-id', {}, { client_id: 'client-id' }, []],
{ status_str: 'success', messages: [], completed: true }
)
expect(taskItem.errorMessage).toBeUndefined()
})
it('errorMessage returns undefined when status has no messages', () => {
const taskItem = new TaskItemImpl(
'History',
[0, 'prompt-id', {}, { client_id: 'client-id' }, []],
{ status_str: 'error', completed: false } as any
)
expect(taskItem.errorMessage).toBeUndefined()
})
it('errorMessage returns the exception_message from execution_error', () => {
const taskItem = new TaskItemImpl(
'History',
[0, 'prompt-id', {}, { client_id: 'client-id' }, []],
{
status_str: 'error',
completed: false,
messages: [
['execution_start', { prompt_id: 'prompt-id', timestamp: 1 }],
[
'execution_error',
{
prompt_id: 'prompt-id',
timestamp: 2,
node_id: 'node-1',
node_type: 'KSampler',
executed: [],
exception_message: 'GPU out of memory',
exception_type: 'RuntimeError',
traceback: ['line 1', 'line 2'],
current_inputs: {},
current_outputs: {}
}
]
]
}
)
expect(taskItem.errorMessage).toBe('GPU out of memory')
})
it('executionError returns undefined when no execution_error message', () => {
describe('executionError getter', () => {
it('returns undefined when no execution_error message', () => {
const taskItem = new TaskItemImpl(
'History',
[0, 'prompt-id', {}, { client_id: 'client-id' }, []],
@@ -291,7 +243,7 @@ describe('TaskItemImpl', () => {
expect(taskItem.executionError).toBeUndefined()
})
it('executionError returns the full error object from execution_error', () => {
it('returns the full error object from execution_error', () => {
const errorDetail = {
prompt_id: 'prompt-id',
timestamp: 2,

View File

@@ -322,14 +322,6 @@ export class TaskItemImpl {
return this.status?.messages || []
}
/**
* Extracts the execution error message from status messages.
* Used by error reporting UI components.
*/
get errorMessage(): string | undefined {
return this.executionError?.exception_message
}
/**
* Extracts the full execution error from status messages.
* Returns the ExecutionErrorWsMessage for detailed error dialogs.