getCredentials not being called

I am in the process of re-implementing the cloudantStorage code that was originally written for IBM Cloud to use the new Cloudant SDK. It's mainly working, but I'm having problems with flow encryption.

To do this, I am implementing the Storage API. The first time I run Node-RED with Cloudant Storage enabled it creates the database as expected and creates and saves the flow credential. The problem I get is that when I stop and re-run Node-RED it fails to load the previously saved credentials with a syntax error. However, I have put a console log into the new getCredentials function and it's not even being called. Is it possible that there's a problem in the core which is causing this?

Clearly the standard local filesystem storage works fine, it just seems to appear when there's a pluggable storage module added.

I am looking in @node-red/runtime/lib/storage/index.js and it appears to me that the call for getCredentials is commented out from StorageModuleInterface. Is this correct @knolleary ?

Any ideas?

After further investigation, it appears that if credentialSecret is set to anything (false or your own choice of secret) then it works (and doesn't try to store a credentials document in the database). It's only if you let NR choose the default that you get the error.

@knolleary any idea whether is likely to be an error in my code or a bug somewhere in the core?

You are looking at the api layer between the internal storage system and the main runtime. There is not a one-to-one mapping between the internal api and the Storage Plugin API.

Internally, the runtime calls getFlows of the storage layer and that is expected to return both flows and credential objects. Internally, the storage layer calls the Storage Plugin's getFlows and getCredentials to assemble the proper response. See node-red/packages/node_modules/@node-red/runtime/lib/storage/index.js at master · node-red/node-red · GitHub for details.

Could you share the details of the syntax error?

If you were updating node-red-app/cloudantStorage.js at master · IBM/node-red-app · GitHub to use the new SDK library under the covers, I don't see why you'd get different behaviours in the Node-RED <--> plugin interaction.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.