# FR: validationErrors for config-node credentials

**URL:** <https://discourse.nodered.org/t/fr-validationerrors-for-config-node-credentials/83105>\
**Category:** Feature Requests\
**Tags:** editor\
**Created:** [22 November 2023 17:37 UTC](https://discourse.nodered.org/t/fr-validationerrors-for-config-node-credentials/83105 "2023-11-22T17:37:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [22 November 2023 17:37 UTC](https://discourse.nodered.org/t/fr-validationerrors-for-config-node-credentials/83105/1 "2023-11-22T17:37:16Z")

</div>

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?

> <https://github.com/node-red/node-red/issues/4397>
>
> \### Current Behavior
> 
> \<img width="506" alt="Screenshot 2023-10-27 at 16 55 12" s…rc="https://github.com/node-red/node-red/assets/99246719/b5420f69-9fb9-49cc-aa9c-729a1efdacbb"\>
> 
> If a config node has an error in validation, in this case, \`ui-page\` doesn't have a required \`ui-base\` property assigned, then the reporting of this could be much clearer in the "config" side bar of Node-RED.
> 
> \### Expected Behavior
> 
> The relevant \`ui-page\` node in the Node-RED Config panel should show it's error/validation state (e.g. red colouring, or red triangle as per main nodes.)
> 
> \<img width="444" alt="Screenshot 2023-10-27 at 16 56 35" src="https://github.com/node-red/node-red/assets/99246719/fa0e6fd8-402b-4da5-8ea9-fb438ba02ade"\>
> 
> 
> \### Steps To Reproduce
> 
> \_No response\_
> 
> \### Example flow
> 
> \_No response\_
> 
> \### Environment
> 
> \- Node-RED version: 3.0.2

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [30 November 2023 17:07 UTC](https://discourse.nodered.org/t/fr-validationerrors-for-config-node-credentials/83105/2 "2023-11-30T17:07:37Z")

</div>

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

```diff
// 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.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [30 November 2023 17:23 UTC](https://discourse.nodered.org/t/fr-validationerrors-for-config-node-credentials/83105/3 "2023-11-30T17:23:48Z")

</div>

> [@GogoVega](#):
>
> also possible to show that a config node is in error as the following issue suggests?

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.

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [30 November 2023 17:29 UTC](https://discourse.nodered.org/t/fr-validationerrors-for-config-node-credentials/83105/4 "2023-11-30T17:29:28Z")

</div>

> [@knolleary](#):
>
> it is _not_ currently possible to flag config nodes as have errors

This could be the subject of a new functionality 🙂

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

And for context 😁

> <https://github.com/node-red/node-red/blob/fd32ee09ffbc0c23660835b56defa8d1357fd865/packages/node_modules/%40node-red/editor-client/src/js/ui/editor.js#L62-L64>

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [30 November 2023 18:56 UTC](https://discourse.nodered.org/t/fr-validationerrors-for-config-node-credentials/83105/5 "2023-11-30T18:56:13Z")

</div>

> [@GogoVega](#):
>
> This could be the subject of a new functionality

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

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [1 December 2023 12:08 UTC](https://discourse.nodered.org/t/fr-validationerrors-for-config-node-credentials/83105/6 "2023-12-01T12:08:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [11 December 2023 11:20 UTC](https://discourse.nodered.org/t/fr-validationerrors-for-config-node-credentials/83105/7 "2023-12-11T11:20:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [11 December 2023 13:00 UTC](https://discourse.nodered.org/t/fr-validationerrors-for-config-node-credentials/83105/8 "2023-12-11T13:00:31Z")

</div>

Please look at [this](https://github.com/GogoVega/node-red/commit/abb3060cb7a25322f6e1ddea82a91f4bc237a458) 🙂

Found this: [feature: Allow credentials to be marked as required as part of validation · Issue #3420 · node-red/node-red · GitHub](https://github.com/node-red/node-red/issues/3420)

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [17 December 2023 14:25 UTC](https://discourse.nodered.org/t/fr-validationerrors-for-config-node-credentials/83105/9 "2023-12-17T14:25:27Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 February 2024 14:26 UTC](https://discourse.nodered.org/t/fr-validationerrors-for-config-node-credentials/83105/10 "2024-02-15T14:26:16Z")

</div>

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