Extraneous trailing space using expressions

Describe the problem/error/question

Hi,

I encountered a strange behavior where expressions “added” extra trailing space when formatting a string. More specifically:

As shown in the SS, expression {{ `${$('init').item.json.favicon_dir}/default_favicon.png` }} generated an extra trailing space. I also tried {{ ‘/data/shared/favicons/default_favicon.png’ }} and {{ `/data/shared/favicons/default_favicon.png` }}, both resulted in extra trailing space in the output. If I use “Fixed” value, ie /data/shared/favicons/default_favicon.png, then the output without does not contain any extra trailing spaces.

What is the error message (if any)?

N/A

Please share your workflow

Share the output returned by the last node

[
{
“exitCode”: 0,
“stderr”: “”,
“stdout”: “”,
“faviconOutput”: “/data/shared/favicons/feed_id_undefined.ico”,
“defaultIcon”: "/data/shared/favicons/default_favicon.png "
}
]

Information on your n8n setup

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

BTW, I forgot to mention that the first expression “faviconOutput” turned out correctly without any trailing spaces.

Hi @Eric_Shieh

In n8n expressions, everything outside the {{ }} is literal text, including spaces and newlines..

so looking at you expression there is an extra space here:

remove it and you’re okay :slight_smile:

2 Likes

Thank you very much! I was pulling my hair out and couldn’t figure out why, I even thought I had copied a non-printable character from windows explorer but that wasn’t the case.

1 Like

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