CREDENTIALS_OVERWRITE_DATA not working?

Hi! Maybe I’m getting the docs wrong, but I believe CREDENTIALS_OVERWRITE_DATA env variable is not working as designed.

I’m using a custom node and custom credential type “companyAuth” (with “auth_key” property) - which works well. I try to deploy an n8n docker instance with hardcoded companyAuth credential so users can not reveal it and not modify it.

My understanding is that during the workflow creation user create a dummy “companyAuth” credential with dummy “auth_key” property which during workflow executed is substituted by the overwrite. Apparently this is not the case.

What is happening:

  • I’m adding an env variable: CREDENTIALS_OVERWRITE_DATA={“companyAuth”:{“auth_key”:“test_key”}}
  • after n8n start - I can not open nor edit nor add any credential of type “companyAuth” because the UI is showing empty window (form for “auth_key” is missing as well as credential details)
  • credentials values during workflow execution are not being substituted (I print credentials values to debug console).

Here is the credential code:


export class CompanyAuth implements ICredentialType {
    name = 'companyAuth';
    displayName = 'Company Authentication';
    properties: INodeProperties[] = [
        {
            displayName: 'Authentication key',
            name: 'auth_key',
            type: 'string',
            default: '',
        },
    ];
}

Information on your n8n setup

  • n8n version: 0.181
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Hey @grumpy_pirate, welcome to the community!

  • after n8n start - I can not open nor edit nor add any credential of type “companyAuth” because the UI is showing empty window (form for “auth_key” is missing as well as credential details)

Tbh, I am not entirely sure if this is expected or not. A simple workaround would be to add a dummy field to your credentials which users can write any value into (and which is ignored by our node).

I tried this out on my side using the n8n-nodes-starter example repository. I have then added the example credentials and a cheeky console.log to the example node code, so my ExampleNode.node.ts looks like this:

ExampleNode.node.ts
import { IExecuteFunctions } from 'n8n-core';
import {
	INodeExecutionData,
	INodeType,
	INodeTypeDescription
} from 'n8n-workflow';


export class ExampleNode implements INodeType {
	description: INodeTypeDescription = {
		displayName: 'Example Node',
		name: 'exampleNode',
		group: ['transform'],
		version: 1,
		description: 'Basic Example Node',
		defaults: {
			name: 'Example Node',
			color: '#772244',
		},
		inputs: ['main'],
		outputs: ['main'],
		credentials: [
			{
					name: 'exampleCredentials',
					required: true,
			},
		],
		properties: [
			// Node properties which the user gets displayed and
			// can change on the node.
			{
				displayName: 'My String',
				name: 'myString',
				type: 'string',
				default: '',
				placeholder: 'Placeholder value',
				description: 'The description text',
			},
		],
	};


	async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {

		const credentials = await this.getCredentials('exampleCredentials');
		console.log(credentials);

		const items = this.getInputData();

		let item: INodeExecutionData;
		let myString: string;

		// Itterates over all input items and add the key "myString" with the
		// value the parameter "myString" resolves to.
		// (This could be a different value for each item in case it contains an expression)
		for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
			myString = this.getNodeParameter('myString', itemIndex, '') as string;
			item = items[itemIndex];

			item.json['myString'] = myString;
		}

		return this.prepareOutputData(items);

	}
}

After launching n8n with CREDENTIALS_OVERWRITE_DATA='{"exampleCredentials": {"user": "mutedjam"}}' ./node_modules/n8n/bin/n8n start the credentials screen for my example credentials then looks like so (with no user field shown and with me being able to save the credentials):

After creating these credentials I can see that the override works as expected when executing the node and checking the console output:

$ CREDENTIALS_OVERWRITE_DATA='{"exampleCredentials": {"user": "mutedjam"}}' ./node_modules/n8n/bin/n8n start
Initializing n8n process
n8n ready on 0.0.0.0, port 5678
Version: 0.181.2

Editor is now accessible via:
http://localhost:5678/

Press "o" to open in Browser.
{ user: 'mutedjam', accessToken: 'foo' }

Would this approach perhaps work for your use case as well?

This workaround works well - thank you! :slight_smile:

1 Like

Glad to hear this works for you, thanks so much for confirming!

You might als want to take a look at the new n8n REST API which lets you automate the credentials setup (so you can save your users from having to do anything manually).

Thank you! :slight_smile: