mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Fix using option.value
as for loop key (no-changelog) (#13458)
Co-authored-by: Elias Meire <elias@meire.dev> Co-authored-by: Tomi Turtiainen <10324676+tomi@users.noreply.github.com>
This commit is contained in:
parent
97ca702f8c
commit
53656a0255
|
@ -18,11 +18,12 @@ import type {
|
||||||
INodeParameterResourceLocator,
|
INodeParameterResourceLocator,
|
||||||
INodeParameters,
|
INodeParameters,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
|
INodePropertyCollection,
|
||||||
INodePropertyOptions,
|
INodePropertyOptions,
|
||||||
IParameterLabel,
|
IParameterLabel,
|
||||||
NodeParameterValueType,
|
NodeParameterValueType,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
import { CREDENTIAL_EMPTY_VALUE, NodeHelpers } from 'n8n-workflow';
|
import { CREDENTIAL_EMPTY_VALUE, isINodePropertyOptions, NodeHelpers } from 'n8n-workflow';
|
||||||
|
|
||||||
import CodeNodeEditor from '@/components/CodeNodeEditor/CodeNodeEditor.vue';
|
import CodeNodeEditor from '@/components/CodeNodeEditor/CodeNodeEditor.vue';
|
||||||
import CredentialsSelect from '@/components/CredentialsSelect.vue';
|
import CredentialsSelect from '@/components/CredentialsSelect.vue';
|
||||||
|
@ -66,7 +67,9 @@ import type { EventBus } from '@n8n/utils/event-bus';
|
||||||
import { createEventBus } from '@n8n/utils/event-bus';
|
import { createEventBus } from '@n8n/utils/event-bus';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { useElementSize } from '@vueuse/core';
|
import { useElementSize } from '@vueuse/core';
|
||||||
|
import { captureMessage } from '@sentry/vue';
|
||||||
import { completeExpressionSyntax, isStringWithExpressionSyntax } from '@/utils/expressions';
|
import { completeExpressionSyntax, isStringWithExpressionSyntax } from '@/utils/expressions';
|
||||||
|
import { isPresent } from '@/utils/typesUtils';
|
||||||
import CssEditor from './CssEditor/CssEditor.vue';
|
import CssEditor from './CssEditor/CssEditor.vue';
|
||||||
|
|
||||||
type Picker = { $emit: (arg0: string, arg1: Date) => void };
|
type Picker = { $emit: (arg0: string, arg1: Date) => void };
|
||||||
|
@ -422,14 +425,11 @@ const editorLanguage = computed<CodeNodeEditorLanguage>(() => {
|
||||||
return getArgument<CodeNodeEditorLanguage>('editorLanguage') ?? 'javaScript';
|
return getArgument<CodeNodeEditorLanguage>('editorLanguage') ?? 'javaScript';
|
||||||
});
|
});
|
||||||
|
|
||||||
const parameterOptions = computed<INodePropertyOptions[] | undefined>(() => {
|
const parameterOptions = computed(() => {
|
||||||
if (!hasRemoteMethod.value) {
|
const options = hasRemoteMethod.value ? remoteParameterOptions.value : props.parameter.options;
|
||||||
// Options are already given
|
const safeOptions = (options ?? []).filter(isValidParameterOption);
|
||||||
return props.parameter.options as INodePropertyOptions[];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Options get loaded from server
|
return safeOptions;
|
||||||
return remoteParameterOptions.value;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const isSwitch = computed(
|
const isSwitch = computed(
|
||||||
|
@ -571,6 +571,12 @@ const shouldCaptureForPosthog = computed(() => {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function isValidParameterOption(
|
||||||
|
option: INodePropertyOptions | INodeProperties | INodePropertyCollection,
|
||||||
|
): option is INodePropertyOptions {
|
||||||
|
return isINodePropertyOptions(option) && isPresent(option.value) && isPresent(option.name);
|
||||||
|
}
|
||||||
|
|
||||||
function isRemoteParameterOption(option: INodePropertyOptions) {
|
function isRemoteParameterOption(option: INodePropertyOptions) {
|
||||||
return remoteParameterOptionsKeys.value.includes(option.name);
|
return remoteParameterOptionsKeys.value.includes(option.name);
|
||||||
}
|
}
|
||||||
|
@ -1084,6 +1090,28 @@ watch(isModelValueExpression, async (isExpression, wasExpression) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Investigate invalid parameter options
|
||||||
|
// Sentry issue: https://n8nio.sentry.io/issues/6275981089/?project=4503960699273216
|
||||||
|
const unwatchParameterOptions = watch(
|
||||||
|
[remoteParameterOptions, () => props.parameter.options],
|
||||||
|
([remoteOptions, options]) => {
|
||||||
|
const allOptions = [...remoteOptions, ...(options ?? [])];
|
||||||
|
const invalidOptions = allOptions.filter((option) => !isValidParameterOption(option));
|
||||||
|
|
||||||
|
if (invalidOptions.length > 0) {
|
||||||
|
captureMessage('Invalid parameter options', {
|
||||||
|
level: 'error',
|
||||||
|
extra: {
|
||||||
|
invalidOptions,
|
||||||
|
parameter: props.parameter.name,
|
||||||
|
node: node.value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
unwatchParameterOptions();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
onUpdated(async () => {
|
onUpdated(async () => {
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue