Skip to content

Commit

Permalink
fix(core): Prevent node param resolution from failing telemetry graph…
Browse files Browse the repository at this point in the history
… generation (n8n-io#9257)
  • Loading branch information
ivov authored Apr 30, 2024
1 parent 96f02bd commit f6c9493
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
22 changes: 14 additions & 8 deletions packages/workflow/src/TelemetryHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,20 @@ export function generateNodesGraph(
return;
}

const nodeParameters =
getNodeParameters(
stickyType.description.properties,
stickyNote.parameters,
true,
false,
stickyNote,
) ?? {};
let nodeParameters: IDataObject = {};

try {
nodeParameters =
getNodeParameters(
stickyType.description.properties,
stickyNote.parameters,
true,
false,
stickyNote,
) ?? {};
} catch {
// prevent node param resolution from failing graph generation
}

const height: number = typeof nodeParameters.height === 'number' ? nodeParameters.height : 0;
const width: number = typeof nodeParameters.width === 'number' ? nodeParameters.width : 0;
Expand Down
14 changes: 13 additions & 1 deletion packages/workflow/test/TelemetryHelpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import {
getDomainBase,
getDomainPath,
} from '@/TelemetryHelpers';
import type { IWorkflowBase } from '@/index';
import { ApplicationError, STICKY_NODE_TYPE, type IWorkflowBase } from '@/index';
import { nodeTypes } from './ExpressionExtensions/Helpers';
import { mock } from 'jest-mock-extended';
import * as nodeHelpers from '@/NodeHelpers';

describe('getDomainBase should return protocol plus domain', () => {
test('in valid URLs', () => {
Expand Down Expand Up @@ -763,6 +765,16 @@ describe('generateNodesGraph', () => {
webhookNodeNames: [],
});
});

test('should not fail on error to resolve a node parameter for sticky node type', () => {
const workflow = mock<IWorkflowBase>({ nodes: [{ type: STICKY_NODE_TYPE }] });

jest.spyOn(nodeHelpers, 'getNodeParameters').mockImplementationOnce(() => {
throw new ApplicationError('Could not find property option');
});

expect(() => generateNodesGraph(workflow, nodeTypes)).not.toThrow();
});
});

function validUrls(idMaker: typeof alphanumericId | typeof email, char = CHAR) {
Expand Down

0 comments on commit f6c9493

Please sign in to comment.