Custom storage module: credentials not being restored

Hey there,

my team develops/modifies a custom storage module which uses MongoDB to store the Node-RED runtime data. The reason for this is that we deploy Node-RED to Cloud Foundry which leads to a lost state if Node-RED is restarted. So with the custom storage module we store the configuration in a persistent database.

The module works fine, except for the recovery of node credentials. If I restart Node-RED, all the flows and nodes are restored perfectly, but the credentials input fields are empty. If I enter them manually and deploy the flow, everything works fine and the credentials get updated in the DB. But after the next restart they are gone again.
The saveCredentials() and getCredentials() functions of the module seem to work fine, since the credentials are stored in the DB and also read from there successfully (I can see the data in the logs of the storage module). I set the log level to "trace" and switched on metrics and audits, but did not find any message that indicates any problem with restoring the credentials. Here is an excerpt from the logs:

[OUT] simple Load(494935d8-c957-4005-bb47-b9c79dff0627/credentials):/
[OUT] simple Load: document -{"type":["credentials"],"path":["/"],"instance":["494935d8-c957-4005-bb47-b9c79dff0627"],"_id":"5c35f0e90590cf004c709ccd","body":"{\"$\":\"753fea2adb72d49a36b1de1767e4a9546eo=\"}","__v":0}
[OUT] parsing '{"$":"753fea2adb72d49a36b1de1767e4a9546eo="}'
[OUT] 11 Jan 14:43:59 - [debug] loaded flow revision: 2fa97972f5d7d8eec77c15a5c03df7de
[OUT] 11 Jan 14:43:59 - [debug] red/runtime/nodes/credentials.load : user provided key
[OUT] 11 Jan 14:43:59 - [debug] red/runtime/nodes/credentials.load : keyType=user
[OUT] 11 Jan 14:43:59 - [trace] runtime event: {"id":"runtime-state","retain":true}
[OUT] 11 Jan 14:43:59 - [trace] runtime event: {"id":"runtime-deploy","payload":{"revision":"2fa97972f5d7d8eec77c15a5c03df7de"},"retain":true}
[OUT] 11 Jan 14:43:59 - [info] Starting flows
[OUT] 11 Jan 14:43:59 - [debug] red/nodes/flows.start : starting flow : global
[OUT] 11 Jan 14:43:59 - [debug] red/nodes/flows.start : starting flow : b21e64d2.bcc3e8
[OUT] 11 Jan 14:43:59 - [debug] red/nodes/flows.start : starting flow : 9a37cbaa.948ae8
[OUT] 11 Jan 14:43:59 - [debug] red/nodes/flows.start : starting flow : 4d64e0ce.866c2
[OUT] 11 Jan 14:43:59 - [trace] runtime event: {"id":"runtime-state","retain":true}
[OUT] 11 Jan 14:43:59 - [info] Started flows
[OUT] 11 Jan 14:43:59 - [error] [MySQLdatabase:42947469.0b2e6c] Error: ER_ACCESS_DENIED_ERROR: Access denied for user ''@'10.0.17.3' (using password: NO)

The first three outputs come from the custom storage module and you can see that it retrieves the credentials correctly from the database. The last output shows the mysql node not being able to connect to the server since the credentials are missing.

Does anyone have any idea what the problem might be or how to investigate further?

Thanks!

Benjamin