mDeploy failing after DHF, Gradle and Marklogic upgrades

63 Views Asked by At

We have upgraded MarkLogic (from 10.07 to 11.0.0), Gradle(5.2.1 to 6.4) and DHF(5.2.0 to 5.8.1). All the upgrades were successful and mlDeploy for 3 out of our 4 code bases also executed successfully.

But, mlDeploy for one code base is failing with the following errors while it is executing without any errors in environments where upgrades have not been done yet:

Gradle error:

> Task :mlDeployApp FAILED
:mlDeployApp (Thread[Daemon worker,5,main]) completed. Took 3 mins 16.45 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mlDeployApp'.
> Error occurred while loading REST modules: Error occurred while loading modules; host: localhost; port: 8011; cause: Local message: config/resources write failed: Bad Request. Server Message: RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: invalid assemblySegmentation extension: could not parse JavaScript extension assemblySegmentation; please see the server error log for detail JS-JAVASCRIPT:     const bdsQuery = cts.andQuery([ -- Error running JavaScript request: SyntaxError: Unexpected identifier; assemblySegmentation either is not a valid JavaScript module or does not export functions (delete, get, put, post)

MarklLogic error log:

2023-11-06 12:45:52.180 Notice:+  $body = document{text{"const segmentation = require('/custom-modules/segmentationLib..."}}
2023-11-06 12:45:52.777 Info: Status 500: RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: invalid assemblySegmentation extension: could not parse JavaScript extension assemblySegmentation; please see the server error log for detail JS-JAVASCRIPT: Â  Â  const bdsDocument = fn.head(cts.search(bdsQuery)); //bdsPublished Document -- Error running JavaScript request: SyntaxError: Unexpected identifier; assemblySegmentation either is not a valid JavaScript module or does not export functions (delete, get, put, post)
2023-11-06 12:45:53.320 Info: <error:error xsi:schemaLocation="http://marklogic.com/xdmp/error error.xsd" xmlns:error="http://marklogic.com/xdmp/error" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2023-11-06 12:45:53.320 Info:+  <error:code>JS-JAVASCRIPT</error:code>
2023-11-06 12:45:53.320 Info:+  <error:name/>
2023-11-06 12:45:53.320 Info:+  <error:xquery-version>javascript</error:xquery-version>
2023-11-06 12:45:53.320 Info:+  <error:message>Error running JavaScript request</error:message>
2023-11-06 12:45:53.320 Info:+  <error:format-string>JS-JAVASCRIPT: Â  Â  const bdsDocument = fn.head(cts.search(bdsQuery)); //bdsPublished Document -- Error running JavaScript request: SyntaxError: Unexpected identifier</error:format-string>
2023-11-06 12:45:53.320 Info:+  <error:retryable>false</error:retryable>
2023-11-06 12:45:53.320 Info:+  <error:expr>Â  Â  const bdsDocument = fn.head(cts.search(bdsQuery)); //bdsPublished Document</error:expr>
2023-11-06 12:45:53.320 Info:+  <error:data>
2023-11-06 12:45:53.320 Info:+    <error:datum>SyntaxError: Unexpected identifier</error:datum>
2023-11-06 12:45:53.320 Info:+  </error:data>
2023-11-06 12:45:53.320 Info:+  <error:stack>
2023-11-06 12:45:53.320 Info:+    <error:frame>
2023-11-06 12:45:53.320 Info:+      <error:uri>/custom-modules/kcqty-lib/pbsEffLib.sjs</error:uri>
2023-11-06 12:45:53.320 Info:+      <error:line>525</error:line>
2023-11-06 12:45:53.320 Info:+      <error:column>7</error:column>
2023-11-06 12:45:53.320 Info:+      <error:xquery-version>javascript</error:xquery-version>
2023-11-06 12:45:53.320 Info:+    </error:frame>
2023-11-06 12:45:53.320 Info:+    <error:frame>
2023-11-06 12:45:53.320 Info:+      <error:uri>[anonymous]</error:uri>
2023-11-06 12:45:53.320 Info:+      <error:line>1</error:line>
2023-11-06 12:45:53.320 Info:+      <error:column>0</error:column>
2023-11-06 12:45:53.320 Info:+      <error:xquery-version>javascript</error:xquery-version>
2023-11-06 12:45:53.320 Info:+    </error:frame>
2023-11-06 12:45:53.320 Info:+    <error:frame>
2023-11-06 12:45:53.320 Info:+      <error:uri>/marklogic.rest.resource/pbsEff/assets/resource.sjs</error:uri>
2023-11-06 12:45:53.320 Info:+      <error:line>2</error:line>
2023-11-06 12:45:53.320 Info:+      <error:column>18</error:column>
2023-11-06 12:45:53.320 Info:+      <error:operation>xdmp:eval("require(&amp;quot;/marklogic.rest.resource/pbsEff/assets/resource.sj...")</error:operation>
2023-11-06 12:45:53.320 Info:+      <error:xquery-version>javascript</error:xquery-version>
2023-11-06 12:45:53.320 Info:+    </error:frame>

What could be the reason? Do we need to make any changes to the "sjs"?

1

There are 1 best solutions below

0
On BEST ANSWER

There are some odd looking characters in the error message:

JS-JAVASCRIPT:     const bdsQuery = cts.andQuery([ -- Error running JavaScript request: SyntaxError: Unexpected identifier;

If there was a character encoding issue reading/writing the module, then that can cause JavaScript "Unexpected Identifier" exceptions. https://runjs.app/blog/how-to-solve-unexpected-identifier-error

Refer to this ml-gradle wiki page for ways of explicitly setting the character encoding to avoid character encoding issues that cause multi-byte characters to be read incorrectly: https://github.com/marklogic/ml-gradle/wiki/Encoding-issues