Set Node Outputs Null Despite Correct Input Object from Postgres Node

Hi everyone,

I’m building a sub-workflow (subwf_GetRealtorById) to fetch realtor data from a Supabase Postgres database.

The workflow structure is basically: Start → Set (test input telegram_id) → Postgres (execute query) → Set (format output).

The Postgres node (named “Get Realtor”) executes the query SELECT telegram_id, name, status, access_code FROM public."Realtors" WHERE telegram_id = $1; successfully. When testing with an existing telegram_id (e.g., 12345), I can see in the Input panel of the next node that the Postgres node correctly returns the data, for example:

JSON[ { "telegram_id": 12345, "name": "Test Realtor", "status": "active", "access_code": "testcode123" } ]

The final node is a Set node (“Format Output”) configured as follows:

  • Mode: Manual Mapping
  • Include Other Input Fields: true
  • Fields to Set:
    • Name: realtor_data
    • Type: Object
    • Value (Expression): {{ $node["Get Realtor"].json[0] ?? null }}

The workflow executes successfully without any error messages.

However, when I check the output of the final “Format Output” Set node (both in the node’s Output panel and in the final Execution data view), the realtor_data field consistently shows null instead of the expected realtor object.

I’ve tried changing the Set node Mode to Merge, simplifying the expression, checking input data carefully, but the result remains null.

(What is the error message (if any)?)

There is no error message; the workflow completes successfully, but the output data from the final Set node is incorrect (null instead of the object).

workflow

n8n Version 1.84.3
Database: Supabase Postgres
n8n EXECUTIONS_PROCESS setting (default: own, main): default (own)
Running n8n via: n8n cloud
Operating system: Windows 10

Can you please post your workflow correctly so it shows up interactively? thanks

1 Like

replace the last node with {{ $node[“Get Realtor”].json ?? null }}

its actually not an array, it would be an array if you have multiple JSON keys inside.

If you are happy with the answer, can you please mark my answer as solution. thanks.

1 Like

Weird,

Try to pin the data on the output of postgres: [ { "telegram_id": 12345, "name": "Test Realtor", "status": "active", "access_code": "testcode123" } ]

it should work as mine

everything is correct in the database. where exactly should I fix it?
Screenshot_35

I’m just not sure how the DB actually outputs the data, I have just pinned what you have stated as JSON. this might have been an incorrect assumption.


I have pinned this data but unfortunately it is still there invalid syntax

I made 3 subprocesses. In each of them, the correct data comes to the “Format Output” block. But the output is null . I can’t figure out what the reason is…

Well, its kind of useless duplicating something that doesn’t work on itself.
If I have some time i will try to replicate

So i made a test connecting to the n8n postgresql database to simulate the real data format.

All my tests come back working, the way i described before:

One thing i’m sure of is that trying $json[0] is useless . it becomes only an array when there is an additional levels of keys . this is why at this level you can do e.g. $json[‘realtor_id’]

I stand by my point that it should work this way. something else fishy is going on? Maybe someone else can give some input?

everything started working!
and do you know why? I copied the formula from the forum and pasted it. And there were other quotes…
Because of this, invalid syntax.

Thank you very much for your time and effort!
Sorry, I didn’t figure it out right away…

but I don’t understand how to set up the same logic for the other two nodes…

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