TypeError: The header content contains invalid characters when encountering ™©®’



  • Hello. I am receiving this error when I am am running JSReport as a standalone server. The exact error I get is as follows:

    2019-08-09T19:46:10.858Z - error: Error during processing request at http://localhost:5488/api/report, details: The header content contains invalid characters, stack: TypeError: The header content contains invalid characters
        at validateHeader (_http_outgoing.js:494:11)
        at ServerResponse.setHeader (_http_outgoing.js:498:3)
        at reporter.render.then (D:\Git\Main2\node_modules\jsreport-express\lib\routes.js:59:15)
        at <anonymous>
    

    I have a playground example at https://playground.jsreport.net/w/anon/YhNEBvSB but I am unable to duplicate it in the browser, so it might be specific to submitting a request to the standalone node JS Report Server?

    I updated to node 10.16.2 and I now get this:

    2019-08-09T21:00:40.254Z - error: Error during processing request at http://localhost:5488/api/report, details: Invalid character in header content ["Debug-Logs"], stack: TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Debug-Logs"]
        at ServerResponse.setHeader (_http_outgoing.js:473:3)
        at reporter.render.then (D:\Git\Main2\node_modules\jsreport-express\lib\routes.js:59:15)
    

    Also my jsreport.config.json looks like this:

    {
      "extensions": {
        "authentication": {
          "cookieSession": {
            "secret": "<your strong secret here>"
          },
          "admin": {
            "username": "admin",
            "password": "password"
          },
          "enabled": false
        },
        "scripts": {
          "timeout": 40000,
          "strategy": "http-server"
        }
      },
      "httpPort": 5488,
      "store": {
        "provider": "fs"
      },
      "blobStorage": {
        "provider": "fs"
      },
      "logger": {
        "console": {
          "transport": "console",
          "level": "debug"
        },
        "file": {
          "transport": "file",
          "level": "info",
          "filename": "logs/reporter.log"
        },
        "error": {
          "transport": "file",
          "level": "error",
          "filename": "logs/error.log"
        }
      },
      "allowLocalFilesAccess": true,
      "templatingEngines": {
        "timeout": 60000,
        "strategy": "http-server"
      },
      "chrome": {
        "timeout": 40000
      }
    }
    


  • You are instructing jsreport to add logs to the response header. The value there contains some invalid characters causing the mentioned error.

    Your API request looks the following

    {
      "template": {
        ...
      },
     "options": {
       "debug": { "logsToResponseHeader": true }
     }
    }
    

    To work around the issue you need to avoid passing logs to the response header. In other words stop adding options.debug.logsToResponseHeader to your request.

    FYI The fix for sanitizing response headers is done and will be part of the next release.



  • I might just wait for the next release then, it seems the .NET API defaults to having this option on.

    Could you add a way to pass the options in when using RenderByNameAsync? It's too cumbersome for me to switch to using RenderAsync at this point, but if logToResponseHeader is set to false (or the bug is fixed) for .NET then I don't need the ability to pass options anyways.

    Thanks for the support, love the product so far!



  • Nevermind after looking through your source code it turned out to be easier than I thought (I thought I had to pass the template etc based on the documentation)

                var rs = new ReportingService("http://localhost:5488");
    
                var report = await rs.RenderAsync(new RenderRequest()
                {
                    Template = new Template()
                    {
                        Name = "sales-order"
                    },
                    Data = data,
                    Options = new RenderOptions() { Debug = new DebugOptions() { LogsToResponseHeader = false } }
                });
    

    Just a thought, if the Name property said something about the name of the template to render I would have intuitively tried it. (Right now it says "Readable name, does not need to be unique")


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.