Skip to content

Commit fec04d5

Browse files
authored
fix(editor): Throw expression error on attempting to set variables at runtime (#9229)
1 parent b694e77 commit fec04d5

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

packages/editor-ui/src/stores/environments.ee.store.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { computed, ref } from 'vue';
33
import type { EnvironmentVariable } from '@/Interface';
44
import * as environmentsApi from '@/api/environments.ee';
55
import { useRootStore } from '@/stores/n8nRoot.store';
6+
import { ExpressionError } from 'n8n-workflow';
67

78
export const useEnvironmentsStore = defineStore('environments', () => {
89
const rootStore = useRootStore();
@@ -43,12 +44,21 @@ export const useEnvironmentsStore = defineStore('environments', () => {
4344
return data;
4445
}
4546

46-
const variablesAsObject = computed(() =>
47-
variables.value.reduce<Record<string, string | boolean | number>>((acc, variable) => {
48-
acc[variable.key] = variable.value;
49-
return acc;
50-
}, {}),
51-
);
47+
const variablesAsObject = computed(() => {
48+
const asObject = variables.value.reduce<Record<string, string | boolean | number>>(
49+
(acc, variable) => {
50+
acc[variable.key] = variable.value;
51+
return acc;
52+
},
53+
{},
54+
);
55+
56+
return new Proxy(asObject, {
57+
set() {
58+
throw new ExpressionError('Cannot assign values to variables at runtime');
59+
},
60+
});
61+
});
5262

5363
return {
5464
variables,

0 commit comments

Comments
 (0)