Skip to content

Fix NPE for filter with and predicate in path step#2687

Merged
ChristianGruen merged 1 commit into
BaseXdb:mainfrom
GuntherRademacher:#2687
Jun 3, 2026
Merged

Fix NPE for filter with and predicate in path step#2687
ChristianGruen merged 1 commit into
BaseXdb:mainfrom
GuntherRademacher:#2687

Conversation

@GuntherRademacher
Copy link
Copy Markdown
Member

As reported by Andreas Hengsbach on basex-talk, an NPE can result from

  • a path expression, that has
  • a context value step, with
  • a filter expression, containing
  • an and expression, involving
  • a function call.

E.g.

import module namespace functx = "http://www.functx.com";

<a/>/.[true() and functx:all-whitespace('')]

This can also be reproduced as simple as

()/.[true() and true()]

It is caused by Path.get rewriting a filter expression to a self step with predicates. In the course of this, the predicates are queried for Flag.POS (via mayBePositional()). But when this is done at parse time, FuncRefs are not resolved yet - yielding an NPE for the flags request.

However it is not necessary to do the rewrite this early, an equivalent rewrite is also done at optimization time, in Filter.optimize. So the fix is to just remove it from Path.get.

@ChristianGruen
Copy link
Copy Markdown
Member

…merci

@ChristianGruen ChristianGruen merged commit 81d4e9f into BaseXdb:main Jun 3, 2026
1 check passed
@ChristianGruen ChristianGruen deleted the #2687 branch June 3, 2026 16:46
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

Successfully merging this pull request may close these issues.

2 participants