Skip to content

Commit 9294e2d

Browse files
fix(core): Add empty credential value marker to show empty pw field (n8n-io#6532)
add empty credential value marker to show empty pw field
1 parent d9ed0b3 commit 9294e2d

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

packages/cli/src/credentials/credentials.service.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
INodeCredentialTestResult,
88
INodeProperties,
99
} from 'n8n-workflow';
10-
import { deepCopy, LoggerProxy, NodeHelpers } from 'n8n-workflow';
10+
import { CREDENTIAL_EMPTY_VALUE, deepCopy, LoggerProxy, NodeHelpers } from 'n8n-workflow';
1111
import { Container } from 'typedi';
1212
import type { FindManyOptions, FindOptionsWhere } from 'typeorm';
1313
import { In } from 'typeorm';
@@ -300,16 +300,23 @@ export class CredentialsService {
300300
for (const dataKey of Object.keys(copiedData)) {
301301
// The frontend only cares that this value isn't falsy.
302302
if (dataKey === 'oauthTokenData') {
303-
copiedData[dataKey] = CREDENTIAL_BLANKING_VALUE;
303+
if (copiedData[dataKey].toString().length > 0) {
304+
copiedData[dataKey] = CREDENTIAL_BLANKING_VALUE;
305+
} else {
306+
copiedData[dataKey] = CREDENTIAL_EMPTY_VALUE;
307+
}
304308
continue;
305309
}
306310
const prop = properties.find((v) => v.name === dataKey);
307311
if (!prop) {
308312
continue;
309313
}
310314
if (prop.typeOptions?.password) {
311-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
312-
copiedData[dataKey] = CREDENTIAL_BLANKING_VALUE;
315+
if (copiedData[dataKey].toString().length > 0) {
316+
copiedData[dataKey] = CREDENTIAL_BLANKING_VALUE;
317+
} else {
318+
copiedData[dataKey] = CREDENTIAL_EMPTY_VALUE;
319+
}
313320
}
314321
}
315322

@@ -321,7 +328,7 @@ export class CredentialsService {
321328
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
322329
for (const [key, value] of Object.entries(unmerged)) {
323330
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
324-
if (value === CREDENTIAL_BLANKING_VALUE) {
331+
if (value === CREDENTIAL_BLANKING_VALUE || value === CREDENTIAL_EMPTY_VALUE) {
325332
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
326333
unmerged[key] = replacement[key];
327334
} else if (

packages/editor-ui/src/components/ParameterInput.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ import type {
367367
EditorType,
368368
CodeNodeEditorLanguage,
369369
} from 'n8n-workflow';
370-
import { NodeHelpers } from 'n8n-workflow';
370+
import { NodeHelpers, CREDENTIAL_EMPTY_VALUE } from 'n8n-workflow';
371371
372372
import CredentialsSelect from '@/components/CredentialsSelect.vue';
373373
import ExpressionEdit from '@/components/ExpressionEdit.vue';
@@ -607,6 +607,11 @@ export default defineComponent({
607607
return this.$locale.baseText('parameterInput.loadingOptions');
608608
}
609609
610+
// if the value is marked as empty return empty string, to prevent displaying the asterisks
611+
if (this.value === CREDENTIAL_EMPTY_VALUE) {
612+
return '';
613+
}
614+
610615
let returnValue;
611616
if (this.isValueExpression === false) {
612617
returnValue = this.isResourceLocatorParameter

packages/workflow/src/Constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ export const NODES_WITH_RENAMABLE_CONTENT = new Set([
1414
'n8n-nodes-base.function',
1515
'n8n-nodes-base.functionItem',
1616
]);
17+
18+
// Arbitrary value to represent an empty credential value
19+
export const CREDENTIAL_EMPTY_VALUE =
20+
'__n8n_EMPTY_VALUE_7b1af746-3729-4c60-9b9b-e08eb29e58da' as const;

0 commit comments

Comments
 (0)