Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] eXist-db failing to match the error in the query and throwing different error #5139

Open
marmoure opened this issue Nov 22, 2023 · 0 comments
Assignees
Milestone

Comments

@marmoure
Copy link
Collaborator

marmoure commented Nov 22, 2023

eXide is showing the wrong error when trying to evaluate this query:

xquery version "3.1";

declare function local:parent-collection($collection-path as xs:string) as xs:string? {
   let $parent-collection-path := replace($collection-path, "(/.+)/.*", "$1")
   return
       if ($parent-collection-path eq $collection-path or not(starts-with($parent-collection-path, "/db")))
       then
           ()
       else
           $parent-collection-path
};

declare %private function local:ascend($collection-path as xs:string, $group-name as xs:string, $collection-permission as xs:string) as empty-sequence() {
    if (not(starts-with($collection-path, "/db")))
    then
       ()
    else
       let $_ := sm:add-group-ace(xs:anyURI($collection-path), $group-name, true(), $collection-permission)
       return
            local:ascend(local:parent-collection($collection-path), $group-name, $collection-permission)
};

local:ascend("/db/apps/test-app/test-dir","monex","r-x")
exerr:ERROR The actual return type does not match the sequence type declared in the function's signature: local:ascend(xs:string, xs:string, xs:string) empty-sequence(). Expected cardinality: empty, got 0. [at line 13, column 39, source: String/6893983447689836372]
In function:
	local:ascend(xs:string, xs:string, xs:string) [23:1:String/6893983447689836372]

The issue is saying that the return type of local:ascend is wrong, whilst this has nothing to do with the issue at hand
also it is saying: Expected cardinality: empty, got 0. which should be the same!
The first parameter of local:ascend is expecting xs:string whilst local:parent-collection returns xs:string?.
If I change the first parameter of local:ascend from type xs:string to type xs:string?, then the error goes away.
The fix is not related to the error that is shown, therefore I conclude that eXide/eXist-db is showing the wrong error for the actual problem.

  • eXist 7.0.0-SNAPSHOT 92b8b9d
  • Java 17
  • OS Windows 10
@adamretter adamretter added this to the eXist-6.2.1 milestone Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants