TypeError: Invalid character in header content ["getKeyByValue"]

Hi,

When I'm setting a header in the http out, I get this fatal error.

TypeError: Invalid character in header content ["getKeyByValue"]

That wasnt there before, maybe it started after a nodejs upgrade.

Some help in the right direction would be helpful, thx!

  • Provide version numbers
  • node-red: 2.2.2
  • nodejs: v16.14.1
  • You operating system (where node-red is running):

PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian

  • Show us where you see this?
    Schermafbeelding 2022-04-05 om 15.40.10

See image above

  • Explain what you are doing to cause it (calling endpoint? from postman? from webpage?)

having a http in (get) execute some code / webrequested or other nodes (I have the same problem on multiple flows), create a json object and send it out via http out

  • Grab a copy of the node-red log (it should include a stack trace to help us identify the issue)

will have a look later today

Hi, it is not obvious where or how this error presents.

Could you please ...

  • Provide version numbers
    • node-red
    • nodejs
  • You operating system (where node-red is running)
  • Show us where you see this?
  • Explain what you are doing to cause it (calling endpoint? from postman? from webpage?)
  • Grab a copy of the node-red log (it should include a stack trace to help us identify the issue)

How did you upgrade nodejs? Did you use official node-red update script?
Did you also update node-red at the same time? If so, what was the previous version?

Hi!

Thanks for you reaction. I updated the post with the requested data.
In addition: Im not sure if its liked. But I updated node js a week or so ago, i think it started then. today a node red upgrade via official script, error still there.

Hi, thanks for providing the info.

You said in your original post that this was a fatal error. Is node red actually crashing?

Can you show us your flow, especially the area where the error occurs? Also add a debug node (set to to show complete message) before the HTTP node where this error occurs so that we can see data that goes into the node.

Hi this is a test flow that has the same error

[
    {
        "id": "4c5ad8c7caa80822",
        "type": "tab",
        "label": "Test",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "b6787bb51bdf5eb4",
        "type": "http in",
        "z": "4c5ad8c7caa80822",
        "name": "Test Endpoint",
        "url": "/test/:parameter",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 170,
        "y": 100,
        "wires": [
            [
                "492f71e9ef5cfb9b",
                "2f2132f8d66f9210"
            ]
        ]
    },
    {
        "id": "6f8c6e875075b463",
        "type": "http response",
        "z": "4c5ad8c7caa80822",
        "name": "",
        "statusCode": "",
        "headers": {
            "content-type": "application/json"
        },
        "x": 670,
        "y": 100,
        "wires": []
    },
    {
        "id": "492f71e9ef5cfb9b",
        "type": "function",
        "z": "4c5ad8c7caa80822",
        "name": "Response definition",
        "func": " msg.payload = {\n    result: \"ok\",\n    response: \"request was received\"\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 100,
        "wires": [
            [
                "6f8c6e875075b463"
            ]
        ]
    },
    {
        "id": "2f2132f8d66f9210",
        "type": "debug",
        "z": "4c5ad8c7caa80822",
        "name": "Do something",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 420,
        "y": 180,
        "wires": []
    }
]

Nod red is still running but the flow doesnt seem to but executed

Hi, so there is nothing in that flow I can use to determine the issue.

It appears the error message you are seeing is NOT from a node in that flow you have posted .

If you want further help, please answer / respond to the below...

  • Which node is generating this error ( the one in your screenshot with ID image )

    • you can use CTRL+F to find this node or click the ID in the debug message
  • What is calling the endpoint Test Endpoint?

    • can you provide a CURL that causes this issue?
  • Which node is generating this error, * you can use CTRL+F to find this node or click the ID in the debug message

The HTTP out is causing the error

  • What is calling the endpoint Test Endpoint ?

M2M, but in this test a browser, curl below

  • can you provide a CURL that causes this issue?

Curl is getting no response and times out

Ok, as I said before, your demo flow works for me (which is not surprising) and that I think you did not post the actual flow that is causing this problem since the node ID in your demo flow is different to the ID shown in the debug message.

Lets try something else.

Add a debug node set to show complete message

image

copy the value from debug message using the copy value button

image

paste info a code block reply

```
paste copied value here
```

Hi,

it is the flow!, I created a new one thats why the id was different. result of your question:

infoblock:

{"_msgid":"ba5ea9bf488765f0","payload":{"result":"ok","response":"request was received"},"req":{"_readableState":{"objectMode":false,"highWaterMark":16384,"buffer":{"head":null,"tail":null,"length":0},"length":0,"pipes":[],"flowing":null,"ended":true,"endEmitted":false,"reading":false,"constructed":true,"sync":true,"needReadable":false,"emittedReadable":false,"readableListening":false,"resumeScheduled":false,"errorEmitted":false,"emitClose":true,"autoDestroy":true,"destroyed":false,"errored":null,"closed":false,"closeEmitted":false,"defaultEncoding":"utf8","awaitDrainWriters":null,"multiAwaitDrain":false,"readingMore":true,"dataEmitted":false,"decoder":null,"encoding":null},"_events":{},"_eventsCount":1,"socket":"[internal]","httpVersionMajor":1,"httpVersionMinor":1,"httpVersion":"1.1","complete":true,"rawHeaders":["Host","localhub.homecontrol.erichradstake.nl","User-Agent","curl/7.79.1","Accept","*/*","X-Forwarded-For","82.217.201.115","X-Forwarded-Host","localhub.homecontrol.erichradstake.nl","X-Forwarded-Server","localhub.homecontrol.erichradstake.nl","Connection","Keep-Alive"],"rawTrailers":[],"aborted":false,"upgrade":false,"url":"/test/testparameterparameter","method":"GET","statusCode":null,"statusMessage":null,"client":"[internal]","_consuming":false,"_dumped":false,"baseUrl":"","originalUrl":"/test/testparameterparameter","_parsedUrl":{"protocol":null,"slashes":null,"auth":null,"host":null,"port":null,"hostname":null,"hash":null,"search":null,"query":null,"pathname":"/test/testparameterparameter","path":"/test/testparameterparameter","href":"/test/testparameterparameter","_raw":"/test/testparameterparameter"},"params":{"parameter":"testparameterparameter"},"query":{},"res":"[internal]","route":{"path":"/test/:parameter","stack":[{"name":"cookieParser","keys":[],"regexp":{"__enc__":true,"type":"regexp","data":"/^\\/?$/i"},"method":"get"},{"name":"httpMiddleware","keys":[],"regexp":{"__enc__":true,"type":"regexp","data":"/^\\/?$/i"},"method":"get"},{"name":"corsHandler","keys":[],"regexp":{"__enc__":true,"type":"regexp","data":"/^\\/?$/i"},"method":"get"},{"name":"metricsHandler","keys":[],"regexp":{"__enc__":true,"type":"regexp","data":"/^\\/?$/i"},"method":"get"},{"name":"<anonymous>","keys":[],"regexp":{"__enc__":true,"type":"regexp","data":"/^\\/?$/i"},"method":"get"},{"name":"<anonymous>","keys":[],"regexp":{"__enc__":true,"type":"regexp","data":"/^\\/?$/i"},"method":"get"}],"methods":{"get":true}},"cookies":{},"signedCookies":{}},"res":{}}

These are all the messages:

Schermafbeelding 2022-04-06 om 12.00.30

  • The first is from the do something block
  • The second fron the HTTP-OUT
  • The third one, pastes above from the debug response definiton

I see nothing in that debug capture that would "upset" the http-response node.

In the raw headers, I see the request was made by curl (curl/7.79.1) - can you share the curl command that was used?

Also, for test purposes, can you try making the request from within your node-red like i have done...

[{"id":"b6787bb51bdf5eb4","type":"http in","z":"4c5ad8c7caa80822","name":"Test Endpoint","url":"/test/:parameter","method":"get","upload":false,"swaggerDoc":"","x":1730,"y":100,"wires":[["492f71e9ef5cfb9b","4e089c0a7ddc8dcc"]]},{"id":"6f8c6e875075b463","type":"http response","z":"4c5ad8c7caa80822","name":"","statusCode":"","headers":{"content-type":"application/json"},"x":2210,"y":100,"wires":[]},{"id":"492f71e9ef5cfb9b","type":"function","z":"4c5ad8c7caa80822","name":"Response definition","func":"\n msg.payload = {\n    result: \"ok\",\n    response: \"request was received\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2000,"y":100,"wires":[["6f8c6e875075b463","2402c1c647d720b0"]]},{"id":"cf4a6bf0d5f4ca66","type":"inject","z":"4c5ad8c7caa80822","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1760,"y":260,"wires":[["e0d7bbc72bc581c9"]]},{"id":"e0d7bbc72bc581c9","type":"http request","z":"4c5ad8c7caa80822","name":"REQ - http://localhost:1881/test/123","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://localhost:1881/test/123","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":1980,"y":260,"wires":[["f25c75e4a2d21b88"]]},{"id":"2402c1c647d720b0","type":"debug","z":"4c5ad8c7caa80822","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2180,"y":160,"wires":[]},{"id":"4e089c0a7ddc8dcc","type":"debug","z":"4c5ad8c7caa80822","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1820,"y":160,"wires":[]},{"id":"f25c75e4a2d21b88","type":"debug","z":"4c5ad8c7caa80822","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2200,"y":260,"wires":[]}]

NOTE: you will need to change the URL in the :point_up_2: http-request node to suit your node-red.

Hi, yeah sorry for this strange case.
Calling it internally with you flow results in the same error:
Schermafbeelding 2022-04-06 om 15.02.29

Keep stuck on requesting and therefor no debug 3 result

Curl command was:

curl http://192.168.178.50:1880/test/123

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