You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by "jkershaw3 (via GitHub)" <gi...@apache.org> on 2023/02/03 10:25:59 UTC

[GitHub] [jmeter] jkershaw3 opened a new issue, #5770: XPath and XPath2 extractors insert a new line in the failure message which breaks CSV log file formatting for the listener.

jkershaw3 opened a new issue, #5770:
URL: https://github.com/apache/jmeter/issues/5770

   Using an XPath or XPath2 extractor on a http sampler.
   If the http sampler fails, or the response is empty, or not in the expected format, the extractor fails and appends text to its failure message
   This appended text inserts a new line character before the appended text.
   The new line character is logged by listener when logging the failure message, and breaks the file format when the listener is logging as CSV.
   
   These files
   ass.setFailureMessage(thrown.getLocalizedMessage()+"**\n**See log file for further details.");
   [Line 199 XPath Extractor](https://github.com/apache/jmeter/blob/c7279348335b820c35ee570462cb2e0b4eb1c370/src/components/src/main/java/org/apache/jmeter/extractor/XPathExtractor.java)
   
   ass.setFailureMessage(thrown.getLocalizedMessage()+"**\n**See log file for further details.");
   [Line 165 XPath2] (https://github.com/apache/jmeter/blob/c7279348335b820c35ee570462cb2e0b4eb1c370/src/components/src/main/java/org/apache/jmeter/extractor/XPath2Extractor.java)
   
   Example CSV output : 
   ```
   timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Filename,Latency,Encoding,SampleCount,ErrorCount,Hostname,IdleTime,Connect
   2023/02/03 10:16:46.263,213,Test,502,FailureMessage,Thread Group 1-1,text,false,"Premature end of file.
   See log file for further details.",0,0,1,1,null,,0,ISO-8859-1,1,1,MachineName,0,0
   ```
   
   This should look like 
   ```
   timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Filename,Latency,Encoding,SampleCount,ErrorCount,Hostname,IdleTime,Connect
   2023/02/03 10:16:46.263,213,Test,502,FailureMessage,Thread Group 1-1,text,false,"Premature end of file. See log file for further details.",0,0,1,1,null,,0,ISO-8859-1,1,1,SBGMLXNK094VJCR,0,0
   ```
   
   The problem this causes is the file then cannot be processed as a valid CSV without manually correcting/removing the new lines, eg a post test JMeter report cannot be generated as it cannot read the file as a CSV format.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] vlsi commented on issue #5770: XPath and XPath2 extractors insert a new line in the failure message which breaks CSV log file formatting for the listener.

Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on issue #5770:
URL: https://github.com/apache/jmeter/issues/5770#issuecomment-1554402532

   I think the bug report is invalid.
   
   See https://datatracker.ietf.org/doc/html/rfc4180#section-2
   
   ```
   Fields containing line breaks (CRLF), double quotes, and commas
          should be enclosed in double-quotes.  For example:
   
          "aaa","b CRLF
          bb","ccc" CRLF
          zzz,yyy,xxx
   ```
   
   RFC suggests that it is fine to have a newline inside double-quoted field.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [jmeter] FSchumacher commented on issue #5770: XPath and XPath2 extractors insert a new line in the failure message which breaks CSV log file formatting for the listener.

Posted by "FSchumacher (via GitHub)" <gi...@apache.org>.
FSchumacher commented on issue #5770:
URL: https://github.com/apache/jmeter/issues/5770#issuecomment-1509875631

   You can fix this in your test plan by adding a global JSR 223 Listener, which contains the following Groovy code:
   ```groovy
   sampleResult.assertionResults.each {
   	it.failureMessage = it.failureMessage
   		.replaceAll("\n", "\\\\n")
   }
   ```
   That will replace all `\n` chars with an escaped variant `\\n`.
   PR #5805 should make this hack unnecessary.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org