mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-03 04:00:31 +00:00
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:
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user