Skip to content

Commit

Permalink
Merge branch 'master' into feature/undo-redo
Browse files Browse the repository at this point in the history
* master:
  fix: Stop using prefixed core modules from nodejs (no-changelog) (#4813)
  fix: Refresh credentials when re-entering workflows page (no-changelog) (#4815)
  ci: Update slack notification messages for e2e tests (no-changelog) (#4812)
  refactor(Code Node): Limit n8n item key check (#4737)
  docs: Update README (no-changelog) (#4636)
  fix(core): Fix partial execution with pinned data on child node run (#4764)
  fix(Execute Workflow Node): Update Execute Workflow node info notice text (#4809)
  • Loading branch information
MiloradFilipovic committed Dec 5, 2022
2 parents 4ef36bd + 46c75b9 commit fe17735
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
status: ${{ job.status }}
channel: '#updates-build-alerts'
webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
message: Tests failure for branch `${{ inputs.branch }}` deployed by ${{ inputs.user }}
message: E2E failure for branch `${{ inputs.branch || 'master' }}` deployed by ${{ inputs.user || 'schedule' }} (${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})

- name: Call Success URL - optionally
run: |
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ The official n8n documentation can be found under: [https://docs.n8n.io](https:/

Additional information and example workflows on the n8n.io website: [https://n8n.io](https://n8n.io)

The changelog can be found [here](https://docs.n8n.io/reference/changelog.html) and the list of breaking
The release notes can be found [here](https://docs.n8n.io/reference/release-notes/) and the list of breaking
changes [here](https://github.com/n8n-io/n8n/blob/master/packages/cli/BREAKING-CHANGES.md).

## Usage

- :books: Learn
[how to **install** and **use** it from the command line](https://github.com/n8n-io/n8n/tree/master/packages/cli/README.md)
[how to **use** it from the command line](https://docs.n8n.io/reference/cli-commands/)
- :whale: Learn
[how to run n8n in **Docker**](https://github.com/n8n-io/n8n/tree/master/docker/images/n8n/README.md)
[how to run n8n in **Docker**](https://docs.n8n.io/hosting/installation/docker/)

## Start

Expand Down
22 changes: 21 additions & 1 deletion packages/cli/src/workflows/workflows.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export class WorkflowsService {

/**
* Find the pinned trigger to execute the workflow from, if any.
*
* - In a full execution, select the _first_ pinned trigger.
* - In a partial execution,
* - select the _first_ pinned trigger that leads to the executed node,
* - else select the executed pinned trigger.
*/
static findPinnedTrigger(workflow: IWorkflowDb, startNodes?: string[], pinData?: IPinData) {
if (!pinData || !startNodes) return null;
Expand All @@ -87,7 +92,22 @@ export class WorkflowsService {

const [startNodeName] = startNodes;

return pinnedTriggers.find((pt) => pt.name === startNodeName) ?? null; // partial execution
const parentNames = new Workflow({
nodes: workflow.nodes,
connections: workflow.connections,
active: workflow.active,
nodeTypes: NodeTypes(),
}).getParentNodes(startNodeName);

let checkNodeName = '';

if (parentNames.length === 0) {
checkNodeName = startNodeName;
} else {
checkNodeName = parentNames.find((pn) => pn === pinnedTriggers[0].name) as string;
}

return pinnedTriggers.find((pt) => pt.name === checkNodeName) ?? null; // partial execution
}

static async get(workflow: Partial<WorkflowEntity>, options?: { relations: string[] }) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/DirectoryLoader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'node:path';
import { readFile } from 'node:fs/promises';
import * as path from 'path';
import { readFile } from 'fs/promises';
import glob from 'fast-glob';
import { jsonParse, KnownNodesAndCredentials, LoggerProxy as Logger } from 'n8n-workflow';
import type {
Expand Down
1 change: 1 addition & 0 deletions packages/editor-ui/src/views/NodeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ export default mixins(
this.resetWorkspace();
this.uiStore.stateIsDirty = previousDirtyState;
}
this.loadCredentials();
this.initView().then(() => {
this.stopLoading();
if (this.blankRedirect) {
Expand Down
8 changes: 4 additions & 4 deletions packages/nodes-base/nodes/Code/Sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { normalizeItems } from 'n8n-core';
import { NodeVM, NodeVMOptions } from 'vm2';
import { ValidationError } from './ValidationError';
import { ExecutionError } from './ExecutionError';
import { CodeNodeMode, isObject, N8N_ITEM_KEYS } from './utils';
import { CodeNodeMode, isObject, REQUIRED_N8N_ITEM_KEYS } from './utils';

import type { IExecuteFunctions, IWorkflowDataProxyData, WorkflowExecuteMode } from 'n8n-workflow';

Expand Down Expand Up @@ -104,7 +104,7 @@ export class Sandbox extends NodeVM {
* item keys to be wrapped in `json` when normalizing items below.
*/
const mustHaveTopLevelN8nKey = executionResult.some((item) =>
Object.keys(item).find((key) => N8N_ITEM_KEYS.has(key)),
Object.keys(item).find((key) => REQUIRED_N8N_ITEM_KEYS.has(key)),
);

for (const item of executionResult) {
Expand All @@ -118,7 +118,7 @@ export class Sandbox extends NodeVM {

if (mustHaveTopLevelN8nKey) {
Object.keys(item).forEach((key) => {
if (N8N_ITEM_KEYS.has(key)) return;
if (REQUIRED_N8N_ITEM_KEYS.has(key)) return;
throw new ValidationError({
message: `Unknown top-level item key: ${key}`,
description: 'Access the properties of an item under `.json`, e.g. `item.json`',
Expand Down Expand Up @@ -226,7 +226,7 @@ export class Sandbox extends NodeVM {
// directly on the item, when they intended to add it on the `json` property

Object.keys(executionResult).forEach((key) => {
if (N8N_ITEM_KEYS.has(key)) return;
if (REQUIRED_N8N_ITEM_KEYS.has(key)) return;

throw new ValidationError({
message: `Unknown top-level item key: ${key}`,
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Code/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ function isTraversable(maybe: unknown): maybe is IDataObject {

export type CodeNodeMode = 'runOnceForAllItems' | 'runOnceForEachItem';

export const N8N_ITEM_KEYS = new Set(['json', 'binary', 'error', 'pairedItem', 'index']);
export const REQUIRED_N8N_ITEM_KEYS = new Set(['json', 'binary']);
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class ExecuteWorkflow implements INodeType {
},
{
displayName:
'Any data you pass into this node will be output by the start node of the workflow to be executed. <a href="https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.executeworkflow/" target="_blank">More info</a>',
'Any data you pass into this node will be output by the Execute Workflow Trigger. <a href="https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.executeworkflow/" target="_blank">More info</a>',
name: 'executeWorkflowNotice',
type: 'notice',
default: '',
Expand Down

0 comments on commit fe17735

Please sign in to comment.