Persistent "Invalid character in header content" error in self-hosted n8n with Execute Command node

Hello everyone,

I’m facing a very frustrating and persistent issue with my self-hosted n8n instance (running on Docker) and I’m hoping someone can provide a new perspective.

I’m trying to send a JWT token generated by a Node.js script to an HTTP Request node for authentication with a BoondManager API. The problem is that the HTTP Request node consistently throws the following error:

Invalid character in header content ["x-jwt-client-boondmanager"]

What I’ve already tried:

  • Modifying the Node.js script: Changed console.log(token) to process.stdout.write(token) to prevent newlines (\n). This did not work.

  • Cleaning the output in n8n: I’ve tried multiple expressions in the Edit Fields (Set) node to remove newlines, but the stdout output seems to be corrupted:

    • {{ $json.data.stdout.trim() }}

    • {{ $json.data.stdout.replace(/[\n\r]/g, '') }}

    • {{ $json.data.stdout.toString().replace(/[\n\r]/g, '') }}

  • Observing the output: When I use the replace() function, the output shows more and more \n characters each time, which is highly unusual. This suggests a deeper problem with how the Execute Command node handles the output stream from the shell.

  • Using environment variables: I tried exporting the token as a variable on my host system and referencing it in n8n ({{ process.env.BOOND_TOKEN }}), but this failed because n8n in Docker cannot see the host’s environment variables.

  • Hardcoding the token: I directly pasted the raw token string into the Edit Fields (Set) node, and the workflow succeeded. This confirms that the token itself is correct and the issue is purely with the data being passed from the Execute Command node.

  • Updating n8n: I’ve updated n8n from version 1.109.2 to 1.111.0, but the issue with the Execute Command output persists.

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