Support Article

Invalid escape sequence - Service File rule

SA-36770

Summary



When using a service file to load and create collection cases, the user has a comma-separated csv file where each cell value entered in double quotes. If the cell value enters double quotes the file will not process.

Error Messages

com.pega.pegarules.pub.PRException: Error while parsing: Invalid escape sequence. Escape character must be followed by either field delimiter, or record delimiter, or another escape character
From: (HB9CEAA5908AC37D3575F046D4421FC2C:xx.xx.xx.xxx)
at com.pega.pegarules.integration.engine.internal.mapping.DelimitedParserBase.parse(DelimitedParserBase.java:453)
at com.pega.pegarules.integration.engine.internal.services.file.RuleServiceFile.parseRecordAtTime(RuleServiceFile.java:933)
at com.pega.pegarules.integration.engine.internal.services.file.RuleServiceFile.process(RuleServiceFile.java:1757)
at com.pega.pegarules.integration.engine.internal.services.ServiceSimulator.invokeServiceFile(ServiceSimulator.java:440)
at com.pega.pegarules.integration.engine.internal.services.ServiceSimulator.execute(ServiceSimulator.java:167)
at com.pega.pegarules.integration.engine.internal.util.PRServiceUtils.executeServiceSimulation(PRServiceUtils.java:1921)
at com.pegarules.generated.activity.ra_action_execute_826676c154eb827ac6dc2d43a411dc1b.step7_circum0(ra_action_execute_826676c154eb827ac6dc2d43a411dc1b.java:701)
at com.pegarules.generated.activity.ra_action_execute_826676c154eb827ac6dc2d43a411dc1b.perform(ra_action_execute_826676c154eb827ac6dc2d43a411dc1b.java:250)
at com.pega.pegarules.session.internal.mgmt.Executable.doActivity(Executable.java:3553)
at com.pega.pegarules.session.internal.mgmt.Executable.invokeActivity(Executable.java:10711)
at com.pegarules.generated.activity.ra_action_runruleexecute_10dce25211d8bbd6fd3f9cba17fc8a7c.step12_circum0(ra_action_runruleexecute_10dce25211d8bbd6fd3f9cba17fc8a7c.java:1285)
at com.pegarules.generated.activity.ra_action_runruleexecute_10dce25211d8bbd6fd3f9cba17fc8a7c.perform(ra_action_runruleexecute_10dce25211d8bbd6fd3f9cba17fc8a7c.java:290)
at com.pega.pegarules.session.internal.mgmt.Executable.doActivity(Executable.java:3553)
at com.pega.pegarules.session.internal.mgmt.base.ThreadRunner.runActivitiesAlt(ThreadRunner.java:646)
at com.pega.pegarules.session.internal.mgmt.PRThreadImpl.runActivitiesAlt(PRThreadImpl.java:465)
at com.pega.pegarules.session.internal.engineinterface.service.HttpAPI.runActivities(HttpAPI.java:3203)
at com.pega.pegarules.session.external.engineinterface.service.EngineAPI.processRequestInner(EngineAPI.java:391)
at sun.reflect.GeneratedMethodAccessor73.invoke(Unknown Source)

Steps to Reproduce

  1. Create Service File rule
  2. Method tab set record terminator to \n
  3. Delimited Parserule, define comma separated csv file
  4. CSV file enter 2 or more rows where each cell specified in quotes.

For example:
"value 1", "value 2", "value 3"


Root Cause



This is an expected behaviour as per product design for the case of CSV file. Since the user expects the double quotes to remain, a better approach is to define Custom Delimiter and Escape Character.

Resolution



Perform the following local-change:

Using the Field format “Custom Definition” gives us the privilege choose Delimiter and Escape Character of our choice.





Since, in this use case we are listening to a CSV file, the following configuration in File Listener should suffice:



Published April 20, 2017 - Updated April 27, 2017


0% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.