LCOV - code coverage report
Current view: top level - src/utils - errorSeverityClassification.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 10 10
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import type { MissingMediaCandidate } from '@/platform/workflowErrors/missingMedia/types'
       2              : import type { MissingModelCandidate } from '@/platform/workflowErrors/missingModel/types'
       3              : import { tryNormalizeNodeExecutionId } from '@comfyorg/graph-model/nodeIdentification'
       4              : import type { NodeExecutionId } from '@comfyorg/graph-model/nodeIdentification'
       5              : import type { NodeValidationError } from '@/utils/executionErrorUtil'
       6              : 
       7              : import type { ExecutionErrorWsMessage } from '@comfyorg/api-client/executionTypes'
       8              : import type { NodeError, PromptError } from '@comfyorg/api-client/types'
       9              : import {
      10              :   classifyValidationErrorAbsorption,
      11              :   isMissingNodePromptErrorAbsorbed
      12              : } from './missingResourceAbsorption'
      13              : import type { MissingResourceAbsorption } from './missingResourceAbsorption'
      14              : 
      15              : export interface ErrorSeverityInput {
      16              :   promptError: PromptError | null
      17              :   executionError: ExecutionErrorWsMessage | null
      18              :   nodeErrors: Record<string, NodeError> | null
      19              :   missingModels: readonly MissingModelCandidate[] | null
      20              :   missingMedia: readonly MissingMediaCandidate[] | null
      21              :   hasMissingNodes: boolean
      22              : }
      23              : 
      24              : export interface ErrorClassification {
      25              :   promptError: {
      26              :     error: PromptError
      27              :     isAbsorbed: boolean
      28              :   } | null
      29              :   executionError: {
      30              :     error: ExecutionErrorWsMessage
      31              :     rawNodeId: string | undefined
      32              :     nodeId: NodeExecutionId | null
      33              :   } | null
      34              :   nodeErrors: {
      35              :     rawNodeId: string
      36              :     nodeId: NodeExecutionId | null
      37              :     nodeError: NodeError
      38              :     errors: {
      39              :       error: NodeValidationError
      40              :       absorption: MissingResourceAbsorption | null
      41              :     }[]
      42              :   }[]
      43              :   hasBlockingError: boolean
      44              : }
      45              : 
      46         3655 : export function classifyPanelErrors(
      47              :   input: ErrorSeverityInput
      48              : ): ErrorClassification {
      49         3655 :   const promptError = input.promptError
      50              :     ? {
      51              :         error: input.promptError,
      52              :         isAbsorbed: isMissingNodePromptErrorAbsorbed(
      53              :           input.promptError,
      54              :           input.hasMissingNodes
      55              :         )
      56              :       }
      57              :     : null
      58              : 
      59         3655 :   const executionNodeId = input.executionError?.node_id
      60         3655 :   const rawExecutionNodeId =
      61              :     executionNodeId == null ? undefined : String(executionNodeId)
      62         3655 :   const executionError = input.executionError
      63              :     ? {
      64              :         error: input.executionError,
      65              :         rawNodeId: rawExecutionNodeId,
      66              :         nodeId:
      67              :           rawExecutionNodeId === undefined
      68              :             ? null
      69              :             : tryNormalizeNodeExecutionId(rawExecutionNodeId)
      70              :       }
      71              :     : null
      72              : 
      73         3655 :   const nodeErrors = Object.entries(input.nodeErrors ?? {}).map(
      74              :     ([rawNodeId, nodeError]) => {
      75           24 :       const nodeId = tryNormalizeNodeExecutionId(rawNodeId)
      76           24 :       return {
      77              :         rawNodeId,
      78              :         nodeId,
      79              :         nodeError,
      80              :         errors: nodeError.errors.map((error) => ({
      81              :           error,
      82              :           absorption: nodeId
      83              :             ? classifyValidationErrorAbsorption(
      84              :                 input.missingModels,
      85              :                 input.missingMedia,
      86              :                 error,
      87              :                 nodeId
      88              :               )
      89              :             : null
      90              :         }))
      91              :       }
      92              :     }
      93              :   )
      94              : 
      95         3655 :   const hasBlockingNodeError = nodeErrors.some(({ errors }) =>
      96              :     errors.some(({ absorption }) => !absorption)
      97              :   )
      98              : 
      99         3655 :   return {
     100              :     promptError,
     101              :     executionError,
     102              :     nodeErrors,
     103              :     hasBlockingError:
     104              :       (promptError !== null && !promptError.isAbsorbed) ||
     105              :       executionError !== null ||
     106              :       hasBlockingNodeError
     107              :   }
     108              : }
        

Generated by: LCOV version 2.0-1