Hey n8n Community,
From my understanding of the CLI import:credentials
command documentation, when importing JSON credentials files, if the credential’s ID is specified, then it will be inserted into credentials_entity
with such ID. If the ID exists in the table, its row will be overwritten.
From the docs:
However, I was not able to reproduce such behavior. Instead, the ID is always auto-incremented by the database regardless of the ID defined in the credential’s JSON.
Shouldn’t the credential be inserted in the database with the same ID in the JSON file?
If not, how can I prevent workflows from breaking due to this ID change?
Example
Suppose credentials_entity
is empty:
database=# select id, name from n8n_credentials_entity;
id | name
----+------
And I have an exported credential JSON file:
n8n # cat /var/credentials/mysql.json
{
"id": 1,
"name": "mysql",
"data": "<encripted-data>",
"type": "mySql",
"nodesAccess": [
{ "nodeType": "n8n-nodes-base.mySql", "date": "2022-09-02T19:29:00.552Z" }
],
"createdAt": "2022-09-02T19:29:00.561Z",
"updatedAt": "2022-09-02T19:30:14.370Z"
}
Then I import this credential into N8N:
N8N # n8n import:credentials --separate --input=/var/credentials/
Successfully imported 1 credential.
When searching for the credential in credentials_entity
, it was not added with ID 1
, but simply used the next auto-incremented ID:
database=# select id, name from n8n_credentials_entity;
id | name
----+-------
58 | MySQL
As a consequence, workflows referencing the ID of the JSON file break because they failed to find the credential with such ID.
Thanks in advance.
n8n setup
-
Version:
0.189.1
- Database: Postgres
-
Running n8n with the execution process: Own (
exec n8n start
) - Running n8n via: Docker
- Other: Credentials files are mounted from the host via Docker volume bind mount.