chore: Reuse the version-name detail helper for activity events (#39595)

Co-authored-by: n8n-cat-bot[bot] <n8n-cat-bot[bot]@users.noreply.github.com>
This commit is contained in:
n8n-cat-bot[bot] 2026-09-25 11:47:06 +00:00 committed by GitHub
parent 1333a2c130
commit 2a205c294f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 4 deletions

View File

@ -414,6 +414,37 @@ describe('ActivityEventRelay', () => {
);
});
it.each([
{ label: 'null', name: null },
{ label: 'empty', name: '' },
{ label: 'long', name: 'v'.repeat(2_000) },
])('formats $label version names the same when publishing and updating', async ({ name }) => {
relayWith({ flagOverride: true });
eventService.emit('workflow-activated', {
user,
workflowId: 'workflow1',
workflow: mock<IWorkflowDb>({
id: 'workflow1',
name: 'Lead enrichment',
activeVersion: mock<WorkflowHistory>({ name }),
}),
publicApi: false,
});
eventService.emit('workflow-version-updated', {
user,
workflowId: 'workflow1',
workflowName: 'Lead enrichment',
versionId: 'version1',
versionName: name,
});
await flushPromises();
expect(activityEventRepository.record).toHaveBeenCalledTimes(2);
const [[published], [updated]] = activityEventRepository.record.mock.calls;
expect(updated.data).toEqual({ versionId: 'version1', ...published.data });
});
it('records no version name when unpublishing, which clears the relation first', async () => {
relayWith({ flagOverride: true });

View File

@ -255,7 +255,7 @@ export class ActivityEventRelay extends EventRelay {
workflowId,
workflowName,
versionId,
versionName,
versionName: updatedVersionName,
}: RelayEventMap['workflow-version-updated']) {
await this.record({
category: 'workflow',
@ -265,9 +265,7 @@ export class ActivityEventRelay extends EventRelay {
resourceType: 'workflow',
resourceId: workflowId,
resourceName: workflowName,
// The name is unbounded user input. Left whole it can push `data` past the budget, and an
// over-budget payload is replaced entirely — which would take `versionId` with it.
data: { versionId, ...(versionName ? { versionName: clip(versionName) } : {}) },
data: { versionId, ...versionName(updatedVersionName) },
});
}