fix(core): Improve handling of disabled Set Metrics node (#17085)

This commit is contained in:
Benjamin Schroth
2025-07-08 19:16:08 +02:00
committed by GitHub
parent b980897adf
commit 57b914dcd9
2 changed files with 41 additions and 0 deletions

View File

@@ -1022,6 +1022,46 @@ describe('TestRunnerService', () => {
}
});
it('should throw SET_METRICS_NODE_NOT_CONFIGURED when metrics node is disabled', () => {
const workflow = mock<IWorkflowBase>({
nodes: [
{
id: 'node1',
name: 'Set Metrics',
type: EVALUATION_NODE_TYPE,
typeVersion: 1,
position: [0, 0],
disabled: true,
parameters: {
operation: 'setMetrics',
metrics: {
assignments: [
{
id: '1',
name: 'assignment1',
value: 0.95,
},
],
},
},
},
],
connections: {},
});
expect(() => {
(testRunnerService as any).validateSetMetricsNodes(workflow);
}).toThrow(TestRunError);
try {
(testRunnerService as any).validateSetMetricsNodes(workflow);
} catch (error) {
expect(error).toBeInstanceOf(TestRunError);
expect(error.code).toBe('SET_METRICS_NODE_NOT_CONFIGURED');
expect(error.extra).toEqual({ node_name: 'Set Metrics' });
}
});
it('should throw SET_METRICS_NODE_NOT_CONFIGURED when assignment has null value', () => {
const workflow = mock<IWorkflowBase>({
nodes: [

View File

@@ -108,6 +108,7 @@ export class TestRunnerService {
const unconfiguredMetricsNode = metricsNodes.find(
(node) =>
node.disabled === true ||
!node.parameters ||
!node.parameters.metrics ||
(node.parameters.metrics as AssignmentCollectionValue).assignments?.length === 0 ||