# PaletteLabel v. Type

**URL:** <https://discourse.nodered.org/t/palettelabel-v-type/77408>\
**Category:** Developing Nodes\
**Created:** [10 April 2023 08:25 UTC](https://discourse.nodered.org/t/palettelabel-v-type/77408 "2023-04-10T08:25:50Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [10 April 2023 08:25 UTC](https://discourse.nodered.org/t/palettelabel-v-type/77408/1 "2023-04-10T08:25:50Z")

</div>

Hi There!

Following up from [Confused about potential naming conflicts between module names, node names, and palette or flow management](https://discourse.nodered.org/t/confused-about-potential-naming-conflicts-between-module-names-node-names-and-palette-or-flow-management/75951)

When I created [node-red-contrib-neuralnet-builder (node) - Node-RED](https://flows.nodered.org/node/@gregoriusrippenstein/node-red-contrib-neuralnet-builder) I deliberately chose a type prefix for my nodes to avoid a name clash.

When I uploaded the nodes to the flow/node collection, I noticed that the page was using the [type](https://github.com/gorenje/node-red-contrib-neuralnet-builder/blob/eebadf83c3574ff8a7392cf62c40089a03e279d4/nodes/30-trainer.html#L2) and not the [paletteLabel](https://github.com/gorenje/node-red-contrib-neuralnet-builder/blob/eebadf83c3574ff8a7392cf62c40089a03e279d4/nodes/30-trainer.html#L6) value of the node definition:

![Screen Shot 2023-04-10 at 10.23.57](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/5/45623308686d52b28dba9ec2bad84bcdd4511bee.png)

Is that intentional? Seems confusing for the end user since the paletteLabel is shown in Node-RED if defined, else the type.

Cheers,  
Gregorius

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [10 April 2023 08:50 UTC](https://discourse.nodered.org/t/palettelabel-v-type/77408/2 "2023-04-10T08:50:46Z")

</div>

Hi @gregorius,

It is indeed, just a cosmetic thing on the flows website - I do agree, using the `paletteLabel` if its been set, will be favourable over the type name.

The HTML uses the name of the type here.

> <https://github.com/node-red/flow-library/blob/e1728bfd7a9e0d32a3a3e8d92a34808e839679c0/template/_palettenode.html#L5>

Set here

> <https://github.com/node-red/flow-library/blob/e1728bfd7a9e0d32a3a3e8d92a34808e839679c0/routes/nodes.js#L107>

An enhancement to this can be requested (or even a PR 😉 ), I believe it shouldn't to difficult, only time being a factor for the Maintainers.

> **[GitHub - node-red/flow-library: Node-RED Flow Library](https://github.com/node-red/flow-library)**
>
> Node-RED Flow Library. Contribute to node-red/flow-library development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [10 April 2023 09:12 UTC](https://discourse.nodered.org/t/palettelabel-v-type/77408/3 "2023-04-10T09:12:22Z")

</div>

Thanks for explaining that 👍

On line [107](https://github.com/node-red/flow-library/blob/e1728bfd7a9e0d32a3a3e8d92a34808e839679c0/routes/nodes.js#L107) what is the type? Is it the node definition including the paletteLabel, so that the addition of `def.types[t].paletteLabel = t.paletteLabel` could already work?

In the template the line would then be something like (pseudo code):

```auto
<div class="palette_label" {{#icon}}style="margin-left: 28px"{{/icon}}>{{paletteLabel || name}}</div>

```

That would be great if it was that easy 🙂

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [10 April 2023 09:34 UTC](https://discourse.nodered.org/t/palettelabel-v-type/77408/4 "2023-04-10T09:34:07Z")

</div>

> [@gregorius](#):
>
> of `def.types[t].paletteLabel = t.paletteLabel` could already work?

it depends what is indexed in the schedule, I'm not sure what is/isn't indexed for each node/type  
`paletteLabel` might not be in the indexed object for example.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [10 April 2023 10:54 UTC](https://discourse.nodered.org/t/palettelabel-v-type/77408/5 "2023-04-10T10:54:07Z")

</div>

The problem here is that while the type is guaranteed to be unique between Nodes, I don't think that the palette label is. It would surely be just as confusing to people to have something non-unique? For my nodes, the palette label is the same as the node name.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [10 April 2023 15:47 UTC](https://discourse.nodered.org/t/palettelabel-v-type/77408/6 "2023-04-10T15:47:10Z")

</div>

But that's why there is a category - so I might well have nodes with the same `paletteLabel` but they will hopefully be in different categories.

The convention of using `type` as the label begs the question why have the `paletteLabel` field in the first place? I notice that most packages use type as label, but I found this - because of the global namespace - too risky, hence my use of `paletteLabel` and prefixing the types with a package related prefix.

A globally unique namespace is probably, in the long term, not a good idea. So some convention for namespacing types would probably be required in the long term.

Nodes with the same type will lead to broken flows since the flow might well assume a type that was something completely different when the flow was built but having added a new node collection and suddenly boom, flow is broken.

This is also an attack vector for malicious packages that may redefine the base types such as switch, change and function (for example) and using paletteLabel to hide that fact. Does [flows.nodered.org](http://flows.nodered.org) check for "known" or "reserved" types btw?

---

<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:** [10 April 2023 16:16 UTC](https://discourse.nodered.org/t/palettelabel-v-type/77408/7 "2023-04-10T16:16:06Z")

</div>

> [@gregorius](#):
>
> The convention of using `type` as the label begs the question why have the `paletteLabel` field in the first place?

This is about how the node is shown in the palette, not the workspace.

If a node doesn't specify a custom `paletteLabel` then it will display the type.

As you've noted, type is a global namespace, so need to be unique. That can lead to unwieldy type names that don't look good in the palette. So being able to have a palette specific label is useful.

There are also cases where a node wants to "rebrand" itself, but not have to modify its type (as that would break existing flows). We did exactly that with the `rbe` node that got renamed `filter` - by updating the palette label but not changing the type.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [11 April 2023 06:57 UTC](https://discourse.nodered.org/t/palettelabel-v-type/77408/8 "2023-04-11T06:57:03Z")

</div>

> [@knolleary](#):
>
> As you've noted, type is a global namespace, so need to be unique. That can lead to unwieldy type names that don't look good in the palette. So being able to have a palette specific label is useful.

Is this global namespace something that the maintainers of Node-RED see as problematic? I can definitely understand that for the target audience of NR that a global namespace isn't an issue.

However as might have come clear over the past few months, I really would like to see Node-RED used for a broader range of applications and in that context, a global namespace could become problematic.

One thing I constantly run into is that there are no NR playgrounds like there are [Jupyter](https://jupyter.org/) playgrounds. When talking to friends about NR it's hard to point them to a demo site where they can get a feel/taste for NR.

I definitely don't want the maintainers to change their development plans or spend resources to fulfil these visions/hallucinations, just wondering for me if this has come up before in the NR community? Has anyone setup a read-only server just for having a look at NR? Are there plans for something like that?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [11 April 2023 07:54 UTC](https://discourse.nodered.org/t/palettelabel-v-type/77408/9 "2023-04-11T07:54:43Z")

</div>

> [@gregorius](#):
>
> problematic?

compared to the long list of other problems/issues/new features ?... not really 🙂 It is something we recognised early on, and does come up now and again, but has not been a major issue.

As for playgrounds - initially Node-RED was part of the Raspberry Pi full install and was there by default. (It isn't now as they ran out of space/ got a bit bloated so went for a more sensible default install). If you run docker then you can easily run `docker run -it -p 1880:1880 nodered/node-red` to start up an instance in read only mode. I know that isn't a public playground - but for that someone needs to host and pay for a dedicated server, and set up tooling around it to wipe/maintain it.

And of course there are companies such as Nick's [Flowforge](https://app.flowforge.com/account/create) that offer free online trials.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [11 April 2023 08:42 UTC](https://discourse.nodered.org/t/palettelabel-v-type/77408/10 "2023-04-11T08:42:16Z")

</div>

> [@gregorius](#):
>
> Is this global namespace something that the maintainers of Node-RED see as problematic? I can definitely understand that for the target audience of NR that a global namespace isn't an issue.

Crops up only very occasionally. Usually when someone has cloned an existing node, made some changes and published as something "new". Or when a node developer chooses a name that is too generic. Really no different to any other project that allows public extensibility.

> [@gregorius](#):
>
> However as might have come clear over the past few months, I really would like to see Node-RED used for a broader range of applications and in that context, a global namespace could become problematic.

Any project with the ability to have extensions provided by the public faces the same issue. But Node-RED has 4382 registered extensions as of this morning and is a project that has been going for over a decade. In all that time there haven't been more than a handful of instances, all of which were easily dealt with or worked around.

Really not sure how that relates to broader use?

> [@gregorius](#):
>
> One thing I constantly run into is that there are no NR playgrounds like there are [Jupyter](https://jupyter.org/) playgrounds. When talking to friends about NR it's hard to point them to a demo site where they can get a feel/taste for NR.

Wow! Just tried searching for "node-red online" on Bing and NOTHING came up! Doing the same search on [startpage.com](http://startpage.com) came up with these on the first page:

[Node-RED : playground.mindconnect.rocks](https://playground.mindconnect.rocks/#flow/b49f7b47.d5ff08)  
[Introduction to Node-RED • FlowForge](https://flowforge.com/node-red/)

On the 2nd page, this came up - a bunch of people have managed to get Node-RED running in CodeSandbox!

[node-red examples - CodeSandbox](https://codesandbox.io/examples/package/node-red)

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [11 April 2023 11:12 UTC](https://discourse.nodered.org/t/palettelabel-v-type/77408/11 "2023-04-11T11:12:22Z")

</div>

[https://playground.mindconnect.rocks](https://playground.mindconnect.rocks) is fun - you're dropped straight into a read-only Node-RED instance, no idea what it's doing but you have the instantaneous gratification of the NR experience!

I guess that is kind URL I would give tech friends to say: this is Node-RED! No docker, just an URL and off they can go.

Concerning the global namespace, [flows.nodered.org](http://flows.nodered.org) does do a name check "Nodes have unique names" so I guess there can't actually be any clashes. So it's all rather academic 🙂

---

<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:** [10 June 2023 11:12 UTC](https://discourse.nodered.org/t/palettelabel-v-type/77408/12 "2023-06-10T11:12:26Z")

</div>

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