Data truncation and corruption when passing large text between workflows into PostgreSQL

Describe the problem/error/question

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?

What is the error message (if any)?

Please share your workflow


Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @Lorenzo_Fabiccio, while you wait for a response, here are some things that might help:

Suggested resources

Automatically matched to your question.

Docs:

Forum:

@peurodriguez, @Li_Jia, @Sudhanshu_Sharma - you’ve helped with similar issues before, can you take a look?

Automatically suggested by n8n’s community bot. It’s a pilot - please share feedback here.

Hi @Lorenzo_Fabiccio Welcome!
Nothing is getting corrupted in transit between the workflows. The Postgres node splits the Query Parameters string on every comma, so a long Markdown block is cut at its first comma and everything after it shifts into $2, $3 and so on. Pass the parameters as a JS array instead of a comma-separated expression, keeping $1 and $2 in the query:

{{ [ $json.title, $json.markdown ] }}

Values inside the array keep their own commas and are still sanitized.
See this:

Hey @Lorenzo_Fabiccio

The “corruption” is happening in one specific place: the Query Parameters field of the Postgres node, which is parsed as a comma‑separated list.

If you must keep Execute Query: make the values comma‑proof by Base64‑encoding them.
In the Code node:

const b64 = (s) => Buffer.from(s || '', 'utf8').toString('base64');
// return markdown_b64, title_b64, core_claim_b64 instead of raw strings

and in SQL:

INSERT INTO pipeline_results (session_id, status, result_markdown, pdf_url, title, core_claim)
VALUES ($1, 'done',
        convert_from(decode($2, 'base64'), 'UTF8'), $3,
        convert_from(decode($4, 'base64'), 'UTF8'),
        convert_from(decode($5, 'base64'), 'UTF8'))
ON CONFLICT (session_id) DO UPDATE SET
  result_markdown = convert_from(decode($2, 'base64'), 'UTF8'),
  title = convert_from(decode($4, 'base64'), 'UTF8'),
  core_claim = convert_from(decode($5, 'base64'), 'UTF8'),
  created_at = NOW();

Base64’s alphabet (A–Z a–z 0–9 + / =) contains no commas, so the mapping can’t shift.