PostgreSQL node saves text truncated or with corrupted line breaks from Code node

Hi everyone,

I’m facing a strange issue with my n8n setup (self-hosted on Railway).

I have two workflows. In the first workflow, I generate a long text output (thousands of characters of Markdown from an LLM) and successfully process it inside a Code node.

However, when I pass these data to another workflow to save it into a PostgreSQL database, the text arriving at the Postgres node becomes truncated, broken, and messed up. The data seems to get corrupted or cut off during the transfer between workflows or during the SQL parameter mapping.

The PostgreSQL column is already set to TEXT, but the result is still broken. Has anyone experienced this, or is there a specific way to handle and pass long multi-line text strings between workflows safely?


Thanks for any help!

Hi @Baila_Moreno Welcome!
Nothing is lost between the workflows. The Code node hands over 5386 characters and the Postgres node splits your Query Parameters string on every comma, so $2 stops at the first comma of the Markdown, which is the 118 characters you see stored, and the later fragments shift into $3, $4 and $5. That is why title holds a slice of the Markdown. Put all five values in one JS array so the node stops splitting:

{{ [ $('Webhook').item.json.body.sessionId, $('Code in JavaScript6').item.json.markdown, $('Upload file').item.json.webViewLink, $('Code in JavaScript6').item.json.title, $('Code in JavaScript6').item.json.core_claim ] }}

The query itself stays as it is.
See this: