exist
exist copied to clipboard
[BUG] some XPath exceptions are wrapped in generic exception, resulting in failing tests
Describe the bug
XQTS and XQSuite tests expecting a specific XPath exception to be thrown may fail due to those exceptions being wrapped and re-thrown with an exception of another type.
In one instance err:XPTY0004 was wrapped in a generic org.exist.xquery.XPathException (in #4081)
https://github.com/eXist-db/exist/blob/2682f3b6e9a8275804640c4606a38d54eaef2d17/extensions/modules/file/src/test/xquery/modules/file/sync.xqm#L132-L144
Expected behavior
Exceptions to not be wrapped so that we can test for those errors.
To Reproduce
needs reproducible test, for now you can check out #4081 and modify the test annotation of sync:bad-options-5 to expect %test:assertError("err:XPTY0004")
Here is one example of such a failure in XQTS (there are many more):
<testcase classname="org.exist.xqts.runner.JUnitResultsSerializerActor$XQTSJUnitTest" name="UnaryLookup-018" time="0.0">
<failure message="Expected: 'Error(XPST0003)', but query returned an error: QueryError(ERROR,exerr:ERROR org.exist.xquery.XPathException: err:XPST0003 unexpected token: 1.0 [at line 1, column 54]
)" type="junit.framework.AssertionFailedError">junit.framework.AssertionFailedError: Expected: 'Error(XPST0003)', but query returned an error: QueryError(ERROR,exerr:ERROR org.exist.xquery.XPathException: err:XPST0003 unexpected token: 1.0 [at line 1, column 54] [...]"
/></testcase>
I found a relatively trivial way to reproduce it
xquery version "3.1";
try {
util:eval("(['a', 'b', 'c'], ['b', 'c', 'd'], ['e', 'f', 'b'])[?1.0 = 'a']")
}
catch err:XPST0003 {
"got err:XPST0003"
}
catch * {
"got " || $err:code
}
Context (please always complete the following information):
- OS: macOS 10.15.7
- eXist-db version: tested in 5.3.1 until latest HEAD (5.4.0)
- Java Version Temurin build 1.8.0_312-b07
Additional context
- How is eXist-db installed? build from source
- Any custom changes in e.g.
conf.xml? none
I retested this issue today just out of curiosity.
| exist version | test with the above code |
|---|---|
| 6.2.0 | still affected |
| 6.3.0-SNAPSHOT | still affected |
| 7.0.0-SNAPSHOT | fixed |