FR: validationErrors for config-node credentials

Hi team,
Each node has a validationErrors property which contains either the name of the property in error or a validation error message. It seems that config-nodes do not use this validationErrors property if the validation comes from a credential, @knolleary is this a limitation?

Is it also possible to show that a config node is in error as the following issue suggests?

Hi @knolleary,
I might be wrong but I feel like there is a bug here:

// editor-client -> editor.js
// validateNode function
- if (node._def._creds) {
-     validationErrors = validationErrors.concat(validateNodeProperties(node, node._def.credentials, node._def._creds))
- }
+ if (node.credentials) {
+    validationErrors = validationErrors.concat(validateNodeProperties(node, node._def.credentials, node.credentials))
+ }

Otherwise the config-node never validates these credentials.

As the issue states, it is not currently possible to flag config nodes as have errors.

They simply don't get handled in all the places they should. I haven't started looking at it yet.

It's quite hard to comment on individual lines of code taken out of context here.

This could be the subject of a new functionality :slightly_smiling_face:

What interests me most is being able to get node.validationErrors.

And for context :grin:

Yes. That is why I asked Joe to raise the issue in the first place.

2 Likes

Hi @knolleary,
Do you confirm the issue? I see no other reference to node._def._creds :thinking:

Hi Team,
@knolleary, after delving deeper into the subject, I noticed:

  • A validation of node._def._creds is done but what is it?
  • The credentials (node.credentials) are not validated.

The reason for the last one seems logical... can I suggest validating the defined properties since they are there:

I know that the working of has_ does not allow "safe" validation but it's better to validate what the node can rather than nothing, right?

This will allow to display catchable errors in the future functionality proposed by Joe.

Please look at this :slightly_smiling_face:

Found this: feature: Allow credentials to be marked as required as part of validation · Issue #3420 · node-red/node-red · GitHub

I forgot to mention it:
The problem is that the node credentials are only loaded when the node edit box is opened. Which implies that when loading the workspace the credentials cannot be validated.

Do we leave it like this or do we add the loading of credentials to the loading of the workspace? Of course, for optimal validation credentials is needed...

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