mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix: Load remote resources even if expressions in non requried parameters resolve (#6987)
Github issue / Community forum post (link here to close automatically):
This commit is contained in:
@@ -27,6 +27,8 @@ import type {
|
||||
IExecuteData,
|
||||
INodeConnection,
|
||||
IWebhookDescription,
|
||||
INodeProperties,
|
||||
IWorkflowSettings,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeHelpers } from 'n8n-workflow';
|
||||
|
||||
@@ -39,6 +41,7 @@ import type {
|
||||
XYPosition,
|
||||
ITag,
|
||||
TargetItem,
|
||||
ICredentialsResponse,
|
||||
} from '../Interface';
|
||||
|
||||
import { externalHooks } from '@/mixins/externalHooks';
|
||||
@@ -53,7 +56,6 @@ import { getSourceItems } from '@/utils';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { useRootStore } from '@/stores/n8nRoot.store';
|
||||
import type { IWorkflowSettings } from 'n8n-workflow';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import { useTemplatesStore } from '@/stores/templates.store';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
@@ -62,7 +64,6 @@ import { useEnvironmentsStore } from '@/stores/environments.ee.store';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
import { getWorkflowPermissions } from '@/permissions';
|
||||
import type { IPermissions } from '@/permissions';
|
||||
import type { ICredentialsResponse } from '@/Interface';
|
||||
|
||||
export function resolveParameter(
|
||||
parameter: NodeParameterValue | INodeParameters | NodeParameterValue[] | INodeParameters[],
|
||||
@@ -122,7 +123,7 @@ export function resolveParameter(
|
||||
);
|
||||
|
||||
let runExecutionData: IRunExecutionData;
|
||||
if (executionData === null || !executionData.data) {
|
||||
if (!executionData?.data) {
|
||||
runExecutionData = {
|
||||
resultData: {
|
||||
runData: {},
|
||||
@@ -176,6 +177,47 @@ export function resolveParameter(
|
||||
) as IDataObject;
|
||||
}
|
||||
|
||||
export function resolveRequiredParameters(
|
||||
currentParameter: INodeProperties,
|
||||
parameters: INodeParameters,
|
||||
opts: {
|
||||
targetItem?: TargetItem;
|
||||
inputNodeName?: string;
|
||||
inputRunIndex?: number;
|
||||
inputBranchIndex?: number;
|
||||
} = {},
|
||||
): IDataObject | null {
|
||||
const loadOptionsDependsOn = currentParameter?.typeOptions?.loadOptionsDependsOn ?? [];
|
||||
|
||||
const initial: { required: INodeParameters; nonrequired: INodeParameters } = {
|
||||
required: {},
|
||||
nonrequired: {},
|
||||
};
|
||||
|
||||
const { required, nonrequired }: INodeParameters = Object.keys(parameters).reduce(
|
||||
(accu, name: string) => {
|
||||
const required = loadOptionsDependsOn.includes(name);
|
||||
accu[required ? 'required' : 'nonrequired'][name] = parameters[name];
|
||||
|
||||
return accu;
|
||||
},
|
||||
initial,
|
||||
);
|
||||
|
||||
const resolvedRequired = resolveParameter(required, opts);
|
||||
let resolvedNonrequired: IDataObject | null = {};
|
||||
try {
|
||||
resolvedNonrequired = resolveParameter(nonrequired, opts);
|
||||
} catch (e) {
|
||||
// ignore any expression errors for example
|
||||
}
|
||||
|
||||
return {
|
||||
...resolvedRequired,
|
||||
...(resolvedNonrequired ?? {}),
|
||||
};
|
||||
}
|
||||
|
||||
function getCurrentWorkflow(copyData?: boolean): Workflow {
|
||||
return useWorkflowsStore().getCurrentWorkflow(copyData);
|
||||
}
|
||||
@@ -210,7 +252,7 @@ function connectionInputData(
|
||||
) {
|
||||
connectionInputData = [];
|
||||
} else {
|
||||
connectionInputData = _executeData.data![inputName][nodeConnection.sourceIndex];
|
||||
connectionInputData = _executeData.data[inputName][nodeConnection.sourceIndex];
|
||||
|
||||
if (connectionInputData !== null) {
|
||||
// Update the pairedItem information on items
|
||||
@@ -314,7 +356,7 @@ function executeData(
|
||||
executeData.data = workflowRunData[parentNodeName][runIndex].data!;
|
||||
if (workflowRunData[currentNode] && workflowRunData[currentNode][runIndex]) {
|
||||
executeData.source = {
|
||||
[inputName]: workflowRunData[currentNode][runIndex].source!,
|
||||
[inputName]: workflowRunData[currentNode][runIndex].source,
|
||||
};
|
||||
} else {
|
||||
// The current node did not get executed in UI yet so build data manually
|
||||
@@ -357,6 +399,7 @@ export const workflowHelpers = defineComponent({
|
||||
},
|
||||
methods: {
|
||||
resolveParameter,
|
||||
resolveRequiredParameters,
|
||||
getCurrentWorkflow,
|
||||
getNodes,
|
||||
getWorkflow,
|
||||
@@ -572,9 +615,7 @@ export const workflowHelpers = defineComponent({
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
this.displayParameter(node.parameters, credentialTypeDescription, '', node) === false
|
||||
) {
|
||||
if (!this.displayParameter(node.parameters, credentialTypeDescription, '', node)) {
|
||||
// Credential should not be displayed so do also not save
|
||||
continue;
|
||||
}
|
||||
@@ -661,7 +702,7 @@ export const workflowHelpers = defineComponent({
|
||||
return null;
|
||||
}
|
||||
|
||||
const obj = returnData['__xxxxxxx__'];
|
||||
const obj = returnData.__xxxxxxx__;
|
||||
if (typeof obj === 'object') {
|
||||
const proxy = obj as { isProxy: boolean; toJSON?: () => unknown } | null;
|
||||
if (proxy?.isProxy && proxy.toJSON) return JSON.stringify(proxy.toJSON());
|
||||
@@ -921,7 +962,7 @@ export const workflowHelpers = defineComponent({
|
||||
if (redirect) {
|
||||
void this.$router.replace({
|
||||
name: VIEWS.WORKFLOW,
|
||||
params: { name: workflowData.id as string, action: 'workflowSave' },
|
||||
params: { name: workflowData.id, action: 'workflowSave' },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user