eeditiones / roaster

Open API Router for eXist
GNU General Public License v3.0
23 stars 8 forks source link

Error in function router:error-description if 1st parameter is missing #73

Closed daliboris closed 1 week ago

daliboris commented 7 months ago

If the error description is missing, the roaster raises an exception. Maybe it's a problem of the TEI Publisher application (api-dba.xql library).

<?xml version="1.0" ?>
<exception>
<path>/db/apps/tei-publisher/modules/lib/api-dba.xql</path>
<message>err:XPTY0004 checking function parameter 3 in call map:put($error, &quot;description&quot;, router:error-description(untyped-value-check[xs:string, $error?description], untyped-value-check[xs:integer, $error?line], untyped-value-check[xs:integer, $error?column], untyped-value-check[xs:string, $error?module], $error?value)): XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: router:error-description($description as xs:string, $line as xs:integer?, $column as xs:integer?, $module as xs:string?, $value as item()*) xs:string. Expected cardinality: exactly one, got 0. [at line 424, column 40, source: D:\eXist-db\data\expathrepo\roaster-1.8.1\content\router.xql]
In function:
    router:error-description(xs:string, xs:integer?, xs:integer?, xs:string?, item()*) [424:9:D:\eXist-db\data\expathrepo\roaster-1.8.1\content\router.xql]
    router:default-error-handler(xs:integer, map(*)) [415:9:D:\eXist-db\data\expathrepo\roaster-1.8.1\content\router.xql]
    router:error(xs:integer, map(*), function(*)) [145:17:D:\eXist-db\data\expathrepo\roaster-1.8.1\content\router.xql]
    router:route(xs:string+, function(*), function(*)*) [80:5:D:\eXist-db\data\expathrepo\roaster-1.8.1\content\router.xql]
    roaster:route(xs:string+, function(*)) [20:14:D:\eXist-db\data\expathrepo\roaster-1.8.1\content\roaster.xqm]
 </message>
</exception>
daliboris commented 6 months ago

Example of an internal error that throws the mentioned roaster error (from the eXist-db log file):

25 Apr 2024 18:15:54,490 [qtp920632751-12055] ERROR (LogFunction.java [writeLog]:199) - (Line: 521 /exist/etc/../data/expathrepo/roaster-1.8.1/content/router.xql) [3819e0a7-dd3e-4114-99e0-a7dd3ef11414] post /upload/zip-to/dictionaries: 500
            {"code":"java:java.lang.NullPointerException","description":null,"value":null,"module":null,"line":null,"column":null}
line-o commented 2 months ago

@daliboris Hah! Funny, @DrRataplan just reported this error and we fixed it in the most recent release v1.8.3 :tada:

line-o commented 2 months ago

@daliboris please re-test with this version and confirm that this fixes it for you.

daliboris commented 1 month ago

Today, I got the same error with v1.9.0.

eXist-db log:

08 Sep 2024 19:00:52,874 [qtp105393903-5340] ERROR (LogFunction.java [writeLog]:199) - (Line: 543 /exist/etc/../data/expathrepo/roaster-1.9.0/content/router.xql) [dd5a6d81-439e-4d81-9a6d-81439e1d812a] get /api/collection/volumes: 500
            {"code":"java:java.lang.NullPointerException","description":null,"value":null,"module":null,"line":null,"column":null}

Returned value:

<exception>
<path>/db/apps/vokabular-backend/modules/lib/api.xql</path>
<message>err:XPTY0004 checking function parameter 3 in call map:put($error, "description", router:error-description(untyped-value-check[xs:string, $error?description], untyped-value-check[xs:integer, $error?line], untyped-value-check[xs:integer, $error?column], untyped-value-check[xs:string, $error?module], $error?value)): The actual return type does not match the sequence type declared in the function's signature: router:error-description(xs:string?, xs:integer?, xs:integer?, xs:string?, item()*) xs:string. Expected cardinality: exactly one, got 0. [at line 385, column 52, source: /exist/etc/../data/expathrepo/roaster-1.9.0/content/router.xql] In function: router:error-description(xs:string?, xs:integer?, xs:integer?, xs:string?, item()*) [446:9:/exist/etc/../data/expathrepo/roaster-1.9.0/content/router.xql] router:default-error-handler(xs:integer, map(*)) [437:9:/exist/etc/../data/expathrepo/roaster-1.9.0/content/router.xql] router:error(xs:integer, map(*), function(*)) [161:17:/exist/etc/../data/expathrepo/roaster-1.9.0/content/router.xql] router:route(xs:string+, function(*), function(*)*) [80:5:/exist/etc/../data/expathrepo/roaster-1.9.0/content/router.xql] roaster:route(xs:string+, function(*)) [38:14:/exist/etc/../data/expathrepo/roaster-1.9.0/content/roaster.xqm]</message>
</exception>
DrRataplan commented 1 month ago

Just got the same:

exist log:

2024-09-20 16:28:17,849 [qtp1461744678-190] ERROR (LogFunction.java [writeLog]:199) - (Line: 543 /home/martin/eXist-db/data/expathrepo/roaster-1.9.0/content/router.xql) [e779b43a-0959-460c-b9b4-3a0959c60c7e] get /api/timeline: 500
            {"code":"java:java.lang.ArrayIndexOutOfBoundsException","description":null,"value":null,"module":null,"line":null,"column":null}