-
Type: Bug
-
Status: Resolved
-
Priority: Minor
-
Resolution: Fixed
-
Affects Version/s: 2021.0
-
Component/s: Automation
-
Release Notes Summary:Dashes in Automation operation categories are now escaped.
-
Tags:
-
Backlog priority:650
-
Sprint:nxplatform #94
-
Story Points:3
Steps to reproduce :
- drop the 2 attached jars to nxserver/plugins : they contain the definition of an operation whose category contains a dash : bla-bla (bla-bla.opWithDash) and a script which uses the previous operation
- make a call to the "getAllRelations" script
curl -X POST 'http://localhost:8080/nuxeo/site/automation/javascript.getAllRelations' -H 'Nuxeo-Transaction-Timeout: 300' -H 'X-NXproperties: *' -H 'X-NXRepository: default' -H 'X-NXVoidOperation: false' -H 'content-type: application/json' -d '{"params":{},"input":"/default-domain","context":{}}' -u Administrator:Administrator
- the execution fails with this error
Caused by: javax.script.ScriptException: <eval>:767:7 Expected ; but found - var bla-bla={}; ^ in <eval> at line number 767 at column number 7 at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:477) ~[jdk.scripting.nashorn:?] at jdk.nashorn.api.scripting.NashornScriptEngine.asCompiledScript(NashornScriptEngine.java:503) ~[jdk.scripting.nashorn:?] at jdk.nashorn.api.scripting.NashornScriptEngine.compile(NashornScriptEngine.java:189) ~[jdk.scripting.nashorn:?] at org.nuxeo.automation.scripting.internals.AutomationMapper$ScriptBuilder.build(AutomationMapper.java:257) ~[nuxeo-automation-scripting-2021.17.14.jar:?] at org.nuxeo.automation.scripting.internals.AutomationMapper.compile(AutomationMapper.java:74) ~[nuxeo-automation-scripting-2021.17.14.jar:?] ... 126 more Caused by: jdk.nashorn.internal.runtime.ParserException: <eval>:767:7 Expected ; but found - var bla-bla={}; ^ at jdk.nashorn.internal.parser.AbstractParser.error(AbstractParser.java:297) ~[jdk.scripting.nashorn:?] at jdk.nashorn.internal.parser.AbstractParser.error(AbstractParser.java:282) ~[jdk.scripting.nashorn:?] at jdk.nashorn.internal.parser.AbstractParser.expectDontAdvance(AbstractParser.java:353) ~[jdk.scripting.nashorn:?] at jdk.nashorn.internal.parser.AbstractParser.expect(AbstractParser.java:340) ~[jdk.scripting.nashorn:?] at jdk.nashorn.internal.parser.Parser.endOfLine(Parser.java:5031) ~[jdk.scripting.nashorn:?] at jdk.nashorn.internal.parser.Parser.variableDeclarationList(Parser.java:1688) ~[jdk.scripting.nashorn:?] at jdk.nashorn.internal.parser.Parser.variableStatement(Parser.java:1532) ~[jdk.scripting.nashorn:?] at jdk.nashorn.internal.parser.Parser.statement(Parser.java:1042) ~[jdk.scripting.nashorn:?] at jdk.nashorn.internal.parser.Parser.sourceElements(Parser.java:909) ~[jdk.scripting.nashorn:?] at jdk.nashorn.internal.parser.Parser.program(Parser.java:844) ~[jdk.scripting.nashorn:?] at jdk.nashorn.internal.parser.Parser.parse(Parser.java:325) ~[jdk.scripting.nashorn:?] at jdk.nashorn.internal.parser.Parser.parse(Parser.java:285) ~[jdk.scripting.nashorn:?] at jdk.nashorn.internal.runtime.Context.compile(Context.java:1500) ~[jdk.scripting.nashorn:?] at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:774) ~[jdk.scripting.nashorn:?] at jdk.nashorn.api.scripting.NashornScriptEngine.asCompiledScript(NashornScriptEngine.java:500) ~[jdk.scripting.nashorn:?] at jdk.nashorn.api.scripting.NashornScriptEngine.compile(NashornScriptEngine.java:189) ~[jdk.scripting.nashorn:?] at org.nuxeo.automation.scripting.internals.AutomationMapper$ScriptBuilder.build(AutomationMapper.java:257) ~[nuxeo-automation-scripting-2021.17.14.jar:?] at org.nuxeo.automation.scripting.internals.AutomationMapper.compile(AutomationMapper.java:74) ~[nuxeo-automation-scripting-2021.17.14.jar:?] ... 126 more
Expected behavior: the script is run correctly
Note that AutomationMapper already has a method to replace the dash (replaceDashByUnderscore) and the same change should be applied to the operation id in AutomationMapper#parseAutomationIDSForScripting to fix the issue