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

NullPointerException when there's not next token in HfqlFhirPathParser.determineDatatypeForPath #6720

Open
bratwurzt opened this issue Feb 18, 2025 · 0 comments · May be fixed by #6721
Open

Comments

@bratwurzt
Copy link

bratwurzt commented Feb 18, 2025

When calling:
SELECT deceased FROM Patient WHERE id IN search_match('deceased', 'true') order by meta.lastUpdated

At line 150:
lexer.peekNextToken(HfqlLexerOptions.FHIRPATH_EXPRESSION_PART)

throws an NPE exception.
https://github.com/hapifhir/hapi-fhir/blame/57ee0240d46e1ace94148313750343e320e29606/hapi-fhir-jpaserver-hfql/src/main/java/ca/uhn/fhir/jpa/fql/parser/HfqlFhirPathParser.java#L150C7-L150C7

Solution:
if (childDefForNode != null)
becomes
if (childDefForNode != null && lexer.hasNextToken(HfqlLexerOptions.FHIRPATH_EXPRESSION_PART))

Edit:

I've realized that selecting deceased from Patient is not correct and you should either do it like this:
deceased.ofType(dateTime)
or
deceased.ofType(boolean)

I'll leave this issue for a better formatted exception. Currently it is:
Cannot invoke "ca.uhn.fhir.jpa.fql.parser.HfqlLexerToken.getToken()" because the return value of "ca.uhn.fhir.jpa.fql.parser.HfqlLexer.peekNextToken(ca.uhn.fhir.jpa.fql.parser.HfqlLexerOptions)" is null
with pull request:
"Unexpected end of stream (expected .ofType() function after polymorphic item <item_name>)"

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 a pull request may close this issue.

1 participant