Strange code node stdin behavior

Describe the problem/error/question

Hi,

I encountered a strange behavior where by a linux command executes fine in shell but in code node, I need to block stdin by appending < /dev/nullto the end of the command to avoid error. More specifically, I am running html2markdown CLI in my custom n8n docker container with –input option; if I don’t block stdinwith < /dev/null in the code node, it executed with error:

Command failed: html2markdown --output-overwrite --input /data/shared/archive/1755528222.537633/media/$(jq -r ‘.main_html’ /data/shared/archive/1755528222.537633/media/MHTMLExtractor_URL_Map.json) --output /data/shared/archive/1755528222.537633/page.md

error: cannot use both stdin and --input at the same time. Use either stdin or specify an input file, but not both\n\n

If I run the exact same command in docker container shell, docker exec -it n8n /bin/shell, it runs successfully.

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: 1.105.3
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system:

Hey @Eric_Shieh hope all is good.

One quick solution could be to actually use stdin instead of --input

html2markdown \
--output-overwrite \
--output /data/shared/output_example.md \
< /data/shared/input_example.html

Thank you @jabbson for the alternative suggestion. I was unsure whether html2markdown has any size limits on reading stdin as some of the files could be very large (with Base64 image data) and since I am not familiar with Golang, I didn’t investigate further.

I was able to get it to work by blocking stdin

html2markdown --output-overwrite --input /data/shared/archive/1755528222.537633/media/$(jq -r ‘.main_html’ /data/shared/archive/1755528222.537633/media/MHTMLExtractor_URL_Map.json) --output /data/shared/archive/1755528222.537633/page.md < /dev/null

but I am curious and would love to know why it’s needed since the command (without < /dev/null) works in the shell.

Every time I am trying to send the response, the forum blocks me, I guess something in the response triggers it, here is a screenshot of my answer :man_facepalming:

1 Like

Thank you very much @jabbson for a thorough explanation; very helpful!