# Confusions regarding the level of effort needed to debug a flow

**URL:** <https://discourse.nodered.org/t/confusions-regarding-the-level-of-effort-needed-to-debug-a-flow/83515>\
**Category:** General\
**Tags:** http-request, function-node\
**Created:** [7 December 2023 23:15 UTC](https://discourse.nodered.org/t/confusions-regarding-the-level-of-effort-needed-to-debug-a-flow/83515 "2023-12-07T23:15:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dr94node](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@dr94node](https://discourse.nodered.org/u/dr94node)\
**Post date:** [7 December 2023 23:15 UTC](https://discourse.nodered.org/t/confusions-regarding-the-level-of-effort-needed-to-debug-a-flow/83515/1 "2023-12-07T23:15:01Z")

</div>

I'm new to node red 👋  
I've been programming in node.js as my professional occupation for some years.

I used to have a small automation system build with Huginn which I'm running into some performance issues from time to time so I'm investigating other options.

I don't think Apache Airflow is simple enough for my use case so I pick node red as it seems light weight and I love JavaScript in general.

However I had a rough start, I'm running into a few issues already when migrating one of the simpler workflow I have.

This workflow will retrieve some JSON data from a certain API endpoint and parse it, based on the response it will decide whether it will go one of 2 optional routes, or stop processing the event further.

Sounds simple enough right?

The first problem I run into is that my API key for making the requests can not be properly stored, I cannot find a built in solution for it so I installed a third party package node-red-contrib-credentials .  
I consulted [Node credentials : Node-RED](https://nodered.org/docs/creating-nodes/credentials) but it seems intended for node developers.

The second problem I'm facing is I'm unable to debug the output msg object as a whole, I can only look at one property at a time, by default it is msg.payload, make working with http request node a big hassle because it produces msg.statusCode, msg.headers etc. as well.

The third problem is I quickly realized that I need a whole bunch of debug nodes, pairing with each existing node in order to get a clear picture of what is coming in and out of each node, not to mention it cause filtering logs a heavy labor.

The fourth time I'm surprised to find out that in a function node the node.log will not log into debug panel, only node.warn and node.error log into debug panel... But why? Not to mention the node context is resetting itself if I modify the function node, as a result I have to use flow context instead.

The last problem I had is with the mustache template, it is unclear where it works outside of template node and http request node in the URL field, granted it should be very useful elsewhere.

When compared with Huginn I never had these problems, each agent maintain its own events queue, JavaScript agents can log to its own panel with this.log and liquid template works in every field, memorized values are preserved between modifications.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 December 2023 23:27 UTC](https://discourse.nodered.org/t/confusions-regarding-the-level-of-effort-needed-to-debug-a-flow/83515/2 "2023-12-07T23:27:33Z")

</div>

> [@dr94node](#):
>
> The first problem I run into is that my API key for making the requests can not be properly stored

You can use [context](https://nodered.org/docs/user-guide/context) (memory, file or other)

> [@dr94node](#):
>
> The second problem I'm facing is I'm unable to debug the output msg object as a whole

Double click the debug node  
& choose "show complete message"

> [@dr94node](#):
>
> The fourth time I'm surprised to find out that in a function node the node.log will not log into debug panel, only node.warn and node.error log into debug panel... But why

Historical reasons - there is a topic knocking around.

> [@dr94node](#):
>
> Not to mention the node context is resetting itself if I modify the function node

This is normal. When a node is deployed it is effectively destroyed and recreated. Use flow or global context. Or use file backed context (memory is the default)

Your issues are mostly a matter of familiarity but it is definitely interesting to hear your perspective coming from another platform.

I'm certain things can be improved & this is an open source project - I look forward to seeing you around.

Ps, welcome to the forum and node-red.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 December 2023 23:29 UTC](https://discourse.nodered.org/t/confusions-regarding-the-level-of-effort-needed-to-debug-a-flow/83515/3 "2023-12-07T23:29:39Z")

</div>

Also, here are a couple of canned texts that may help you get a head start (hope you don't mind)...

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

---

<div class="post-metadata">

**Author:** ![dr94node](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@dr94node](https://discourse.nodered.org/u/dr94node)\
**Post date:** [8 December 2023 00:40 UTC](https://discourse.nodered.org/t/confusions-regarding-the-level-of-effort-needed-to-debug-a-flow/83515/4 "2023-12-08T00:40:04Z")

</div>

> [@Steve-Mcl](#):
>
> > [@dr94node](#):
> >
> > The first problem I run into is that my API key for making the requests can not be properly stored
> 
> > You can use [context](https://nodered.org/docs/user-guide/context) (memory, file or other)
> 
> I guess it might not be immediately obvious to me how can I manually put a value to context? If I use a node to modify the context doesn't that means the node itself can expose my credentials & secrets? Well I guess I can just remove the node after the values are set...  
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/b/9b93e8b4e7d745155fb966adc01a7c963ddc0895.png)
> 
> > [@dr94node](#):
> >
> > The second problem I'm facing is I'm unable to debug the output msg object as a whole
> 
> > Double click the debug node  
> > & choose "show complete message"
> 
> ~~Can't seem to find the option, I'm using official docker image, the version seems to be is 3.1.1~~  
> NVM found it.  
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/b/6bf626205113b8c2fec32b2a5838dfcac163b37c.png)
> 
> > [@dr94node](#):
> >
> > The fourth time I'm surprised to find out that in a function node the node.log will not log into debug panel, only node.warn and node.error log into debug panel... But why
> 
> > Historical reasons - there is a topic knocking around.
> 
> Cool good to know.
> 
> > [@dr94node](#):
> >
> > Not to mention the node context is resetting itself if I modify the function node
> 
> > This is normal. When a node is deployed it is effectively destroyed and recreated. Use flow or global context. Or use file backed context (memory is the default)
> 
> From my limited computer programming knowledge regarding this matter, "context" is the setting and surrounding of a certain function(in our case, a node) which seems a bit strange if itself is not kept around due to the code running in it has been modified. This also brings in another question regarding how would one node keep some values to itself without exposing them to other nodes if flow context is recommended by default. Practically I guess one can develop with flow context and switch to node context once the code is verified working but still can be a pain point once there's a need to change the node.
> 
> > Your issues are mostly a matter of familiarity but it is definitely interesting to hear your perspective coming from another platform.
> > 
> > I'm certain things can be improved & this is an open source project - I look forward to seeing you around.
> > 
> > Ps, welcome to the forum and node-red.

Thank you for the quick response, looking forward to my first PR to node-red repo.

---

<div class="post-metadata">

**Author:** ![dr94node](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@dr94node](https://discourse.nodered.org/u/dr94node)\
**Post date:** [8 December 2023 03:30 UTC](https://discourse.nodered.org/t/confusions-regarding-the-level-of-effort-needed-to-debug-a-flow/83515/5 "2023-12-08T03:30:59Z")

</div>

I did a quick count, making a simple workflow to work I manually injected 100+ times😂  
I think Huginn has this "re emit" event feature so I can simply click a random event from second-to-last agent(node in Node-Red) to test the newest agent(node) I've added.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/3/530fab4ad9a15e2afa3385b290c13d7cb27f2180.png)

What for more it can directly dry-run an agent with last few events from upstream, making testing a breeze.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/7/7773eb3fd0746fb84590cf7c55edb689b15c083c.png)

---

<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:** [22 December 2023 03:31 UTC](https://discourse.nodered.org/t/confusions-regarding-the-level-of-effort-needed-to-debug-a-flow/83515/6 "2023-12-22T03:31:02Z")

</div>

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