Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@MarcL
Copy link
Contributor

@MarcL MarcL commented Dec 17, 2025

Summary

Adds two new log streaming events for audit logging:

  • n8n.audit.user.execution.deleted: Emitted when user deletes executions
  • n8n.audit.user.workflow.executed: Emitted when user manually runs or retries a workflow

Both events include user context for audit tracking.

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/PAY-2936

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

…low execution (PAY-2936)

- Add 'execution-deleted' event when user deletes executions
- Add 'workflow-executed' event when user manually runs or retries workflow
- Emit events with user context for audit logging
- Add comprehensive unit tests for both events
@MarcL MarcL changed the title feat(core): Add log streaming events for executions (PAY-2936) feat(core): Add log streaming events for executions Dec 17, 2025
@MarcL MarcL marked this pull request as ready for review December 17, 2025 17:38
@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

❌ Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/cli/src/executions/execution.service.ts 50.00% 1 Missing and 1 partial ⚠️
packages/cli/src/workflows/workflows.controller.ts 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Dec 17, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 8 files

Prompt for AI agents (all 1 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/cli/src/executions/execution.service.ts">

<violation number="1" location="packages/cli/src/executions/execution.service.ts:335">
P2: Audit event may log empty `executionIds` when deletions occur via `deleteBefore` filter. Consider either returning deleted IDs from the repository or including `deleteBefore` in the event payload to provide a complete audit trail.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

@currents-bot
Copy link

currents-bot bot commented Dec 17, 2025

E2E Tests: n8n tests passed after 4m 25s

🟢 31 · 🔴 0 · ⚪️ 4

View Run Details

Run Details

  • Project: n8n

  • Groups: 1

  • Framework: Playwright

  • Run Status: Passed

  • Commit: 79fa0c1

  • Spec files: 15

  • Overall tests: 35

  • Duration: 4m 25s

  • Parallelization: 1


This message was posted automatically by currents.dev | Integration Settings

@blacksmith-sh

This comment has been minimized.

…lete audit trail

When executions are deleted via date filter (deleteBefore), the executionIds
array would be empty. Including deleteBefore in the event payload provides
a complete audit trail showing what criteria was used for bulk deletion.
…ot set

Only include deleteBefore in the payload when it has a value,
rather than including deleteBefore: undefined.
Organize the workflow-executed event listener and handler alongside
other workflow events for better code organization.
@MarcL MarcL requested review from a team and ireneea and removed request for a team and ireneea December 18, 2025 17:15
workflowId: string;
workflowName: string;
executionId: string;
executionMode: 'manual' | 'retry';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there really only "manual" and "retry" modes?
Does this event not concern itself with workflows that are executed by a schedule trigger or webhook trigger etc.?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@konstantintieber I went back and forth on this because we wouldn't have user info for the events that are triggered via other triggers. I chose to just go with the events that were just for the user, as the ticket suggest just needing to know about user triggered events.

Would it be better to have a workflow-executed event with all execution modes, including trigger and error I think - will double-check this, and then have optional user context? WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tricky question indeed.

The audit event name is n8n.audit.user.workflow.executed. From the user, I might infer that this is about manual execution. I guess a non-manual equivalent would be n8n.audit.workflow.executed (following the names we have today)?

The thing is, on the workflow-relay-event-map, the context of the audit event names is missing. So I'm thinking we maybe should use a more specific key there like workflow-executed-manual.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've renamed it to workflow-executed-by-user - does that make more sense now?

Copy link
Contributor

@BGZStephen BGZStephen Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just chucking my opinion in for what it's worth. I'm more a fan of n8n.audit.workflow.executed, and distinguishing the source as being a user (or other), otherwise we may end up with numerous event types just for a workflow execution.

I'd rather have 1 event type, but with multiple filterable fields (source, type, etc) than have multiple event types to wade through.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BGZStephen How about I refactor this to go back to the original workflow executed event and add the source? I might just scope this PR to the user-related changes and then add a 2nd PR to do the non-user events. Thoughts?

And should we do the source like:

'user' | 'schedule' | 'webhook' | 'error' | 'trigger'

And then keep the execution mode? 'manual' | 'retry'

Or use a specific source for manual or retry and no execution mode?
E.g. 'user-manual' | 'user-retry' | 'schedule' | 'webhook' | 'error' | 'trigger'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, user-manual and user-retry make sense to me,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me too

Make the relay event name more explicit that this event is specifically
for user-triggered executions (manual runs and retries), not for all
workflow executions like scheduled or webhook-triggered workflows.

This addresses PR feedback about clarity in the relay event map.
@blacksmith-sh

This comment has been minimized.

Replace workflow-executed-by-user with a generic workflow-executed event
that includes a source field to distinguish execution triggers. This
enables future expansion to non-user sources (webhook, trigger, etc.)
while keeping the current scope to user-triggered executions.

Changes:
- Rename event to workflow-executed with optional user field
- Add source field with all possible execution sources
- Update audit event name to n8n.audit.workflow.executed
- Current sources: user-manual, user-retry (others for future use)
@blacksmith-sh

This comment has been minimized.

… event

Keep only user-manual and user-retry as active sources for now,
with other sources commented out for future PR implementation.
@blacksmith-sh

This comment has been minimized.

@MarcL MarcL merged commit 2f29603 into master Jan 7, 2026
75 of 77 checks passed
@MarcL MarcL deleted the pay-2936-log-streaming-add-executions branch January 7, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants